Mono Support Programatically create a new note in version 5.1 

Viewed 23330 time(s), 2 post(s), 1/19/2016 9:40:19 PM - by nessquick
1/19/2016 9:40:20 PM
15 Reputation 1 Total posts

Hi there, 

I am having issues to create a new note from my code as it seams the method SaveEntity does not apply for the NoteRepository.

Here is the code I am using:
NoteRepository repository = DependencyInjectionFactory.Resolve<NoteRepository>();            
SnNoteEntity note = new SnNoteEntity(GuidExtension.NewSequentialGuid());
note.ApplicationId = DependencyInjectionFactory.Resolve<IMembershipRepository>().GetApplicationId();
note.LanguageId = LocalizationUtility.GetCurrentLanguageId();
note.UserId = SecurityUtility.GetUserId();
note.DateCreated = DateTime.Now;
note.NoteContent = "This is some sample text";            
repository.SaveEntity(note);

The error I am getting pre compilation is 

Error 12 'MonoSoftware.MonoX.Repositories.NoteRepository' does not contain a definition for 'SaveEntity' and no extension method 'SaveEntity' accepting a first argument of type 'MonoSoftware.MonoX.Repositories.NoteRepository' could be found (are you missing a using directive or an assembly reference?) 
           
Could you point me to the right way of achiving this?

Many thanks,

Vanessa

1
1/21/2016 11:06:19 AM
145 Reputation 18 Total posts

Hi,

Reason why you are getting this error is because NoteRepository is not subclass of GenericRepository (which implements IGenericRepository and is used to access DAL layer). 

If you want to save note in your current implementation you should resolve IGenericRepository and save entity with it like so:

DependencyInjectionFactory.Resolve<IGenericRepository>().SaveEntity(note);

Please let us know if you have any other questions.

Regards,
Zeljko

2
This is a demo site for MonoX. Please visit Mono Software for more info.