Example #1
0
 private static PersonMediaModel GetMediaModel(PersonMedia media)
 {
     return(media != null ? new PersonMediaModel
     {
         Id = media.Id,
         Name = media.Name,
         id_Person = media.id_Person,
         id_MediaType = media.id_MediaType,
         MediaLink = media.MediaLink,
         MediaType = media.MediaType.Name,
         Description = media.Description
     } : new PersonMediaModel());
 }
Example #2
0
 /// <see cref="IPersonRepository.UpdateMedia" />
 public PersonMedia UpdateMedia(PersonMedia media, int userId)
 {
     if (media.Id == 0)
     {
         db.Entry(media).State = System.Data.Entity.EntityState.Added;
     }
     else if (media.Id > 0)
     {
         var pr = db.PersonMedia.FirstOrDefault(o => o.Id == media.Id);
         SaveLog(pr, media, media.id_Person, userId, LogType.Media);
         db.Entry(pr).CurrentValues.SetValues(media);
     }
     try
     {
         db.SaveChanges();
     }
     catch (Exception e)
     {
         return(null);
     }
     return(media);
 }