public Operation AddNotification(string message, string url, int id, int EmployeeId, string ntype) { string typeOfNotification = ntype; Operation objOperation = new Operation { Success = true }; try { //START Notification Save SlsNotification notification = new SlsNotification() { Message = message, URL = url + id, Type = typeOfNotification, Date = DateTime.Now }; int notifId = _NotificationRepository.AddEntity(notification); _NotificationRepository.SaveChanges(); SlsNotificationDetail notificationDetail = new SlsNotificationDetail() { SlsNotificationId = notifId, HrmEmployeeId = EmployeeId, IsRead = false, Date = DateTime.Now }; int notifDetailId = _NotificationDetailRepository.AddEntity(notificationDetail); _NotificationDetailRepository.SaveChanges(); //END of Notification Save } catch (Exception ex) { objOperation.Success = false; } return objOperation; }
public Operation Delete(SlsNotification obj) { Operation objOperation = new Operation { Success = true, OperationId = obj.Id }; _NotificationRepository.Delete(obj); try { _UnitOfWork.Commit(); } catch (Exception) { objOperation.Success = false; } return objOperation; }
public Operation UpdateNotification(string message, string url, int id, int EmployeeId, string ntype) { string typeOfNotification = ntype; Operation objOperation = new Operation { Success = true }; try { //START Notification Save SlsNotification notification = new SlsNotification() { Message = message, URL = url + id, Type = typeOfNotification, Date = DateTime.Now }; SlsNotification notificationDB = GetExistingNotification(EmployeeId, notification.URL); notificationDB.Message = notification.Message; notificationDB.URL = notification.URL; notificationDB.Type = notification.Type; notificationDB.Date = notification.Date; _NotificationRepository.Update(notificationDB); _NotificationRepository.SaveChanges(); SlsNotificationDetail notificationDetail = new SlsNotificationDetail() { SlsNotificationId = notificationDB.Id, HrmEmployeeId = EmployeeId, IsRead = false, Date = DateTime.Now }; SlsNotificationDetail notificationDetailDB = GetExistingNotificationDetail(notificationDetail.HrmEmployeeId, notificationDetail.SlsNotificationId); notificationDetailDB.SlsNotificationId = notificationDetail.SlsNotificationId; notificationDetailDB.HrmEmployeeId = notificationDetail.HrmEmployeeId; notificationDetailDB.IsRead = notificationDetail.IsRead; notificationDetailDB.Date = notificationDetail.Date; _NotificationDetailRepository.Update(notificationDetailDB); _NotificationDetailRepository.SaveChanges(); //END of Notification Save } catch (Exception ex) { objOperation.Success = false; } return objOperation; }
public Operation Save(SlsNotification obj) { Operation objOperation = new Operation { Success = true }; long Id = _NotificationRepository.AddEntity(obj); objOperation.OperationId = Id; try { _UnitOfWork.Commit(); } catch (Exception ex) { objOperation.Success = false; } return objOperation; }