public bool UpdateMessage(object dtoItem, out Library.DTO.Notification notification) { List <int> IDs = ((Newtonsoft.Json.Linq.JArray)dtoItem).ToObject <List <int> >(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (NotificationMessageMngEntities context = CreateContext()) { context.NotificationMessage.Where(o => IDs.Contains(o.NotificationMessageID)).ToList().ForEach(o => { o.IsSynced = true; o.SyncedDate = DateTime.Now; }); context.SaveChanges(); return(true); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.HandleExceptionSingleLine(ex); return(false); } }
public List <DTO.NotificationMessageDTO> GetMessage(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; List <DTO.NotificationMessageDTO> data = new List <DTO.NotificationMessageDTO>(); //try to get data try { using (NotificationMessageMngEntities context = CreateContext()) { var result = context.NotificationMessageMng_function_SearMessage(userId).ToList(); data = converter.DB2DTO_NotificationMessageDTO(result); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.HandleExceptionSingleLine(ex); } return(data); }