MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Programatically create a new note in version 5.1  (Mono Support )

Viewed 22179 time(s), 2 post(s) 1/19/2016 9:40:19 PMby nessquick
nessquick

nessquick

1/19/2016 9:40:20 PM
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
This content has not been rated yet. 
15 Reputation 1 Total posts
zhuber

zhuber

1/21/2016 11:06:19 AM
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
This content has not been rated yet. 
145 Reputation 18 Total posts