public NotifictationDto GetById(int id) { NotifictationDto dto = new NotifictationDto(); var item = _unitOfWork.NotifictationRepository.FindById(id); dto.Id = item.Id; dto.SenderName = _unitOfWork.UserRepository.FindById(item.senderId).UserName; dto.RevieverName = _unitOfWork.UserRepository.FindById(item.RevieverId).UserName; dto.IsRead = item.IsRead; if (item.NotText.Contains('&')) { var x = item.NotText.Split('&'); dto.NotText = x[1]; dto.orderId = x[0]; } else { dto.NotText = item.NotText; } dto.Room_ID = item.Room_ID; dto.NotDateTime = item.NotDateTime; dto.RevieverId = item.RevieverId; dto.senderId = item.senderId; return(dto); }
public List <NotifictationDto> All(Guid?userid) { NotifictationDto dto = new NotifictationDto(); List <NotifictationDto> listdto = new List <NotifictationDto>(); var list = _unitOfWork.NotifictationRepository.GetAll().Where(x => x.RevieverId == userid.Value).ToList(); foreach (var item in list) { dto.Id = item.Id; dto.SenderName = _unitOfWork.UserRepository.FindById(item.senderId).UserName; dto.RevieverName = _unitOfWork.UserRepository.FindById(item.RevieverId).UserName; dto.IsRead = item.IsRead; if (item.NotText.Contains('&')) { var x = item.NotText.Split('&'); dto.NotText = x[0]; dto.orderId = x[1]; } else { dto.NotText = item.NotText; } dto.NotDateTime = item.NotDateTime; dto.RevieverId = item.RevieverId; dto.Room_ID = item.Room_ID; dto.senderId = item.senderId; listdto.Add(dto); dto = new NotifictationDto(); } return(listdto); }
public ActionResult AddMaintenanceRequest(int?roomId, int?rromNum) { NotifictationDto dto = new NotifictationDto(); foreach (var item in _RoomService.getReservationEmpIdForRoom(roomId.Value)) { dto.senderId = Guid.Parse(User.Identity.GetUserId()); dto.RevieverId = item; var s1 = "الغرفة رقم"; var s2 = rromNum; var s3 = " بحاجة الى "; var s6 = "تنظيف"; var s7 = "صيانة"; dto.NotText = s1 + s2 + s3 + s7; dto.NotDateTime = DateTimeHelper.ConvertDateToString(Utils.ServerNow.Date, DateFormats.DD_MM_YYYY); dto.Room_ID = roomId; _notifictationService.Add(dto); dto = new NotifictationDto(); } return(RedirectToAction("searchForRoom")); }
public ActionResult SendNotifications(int?id, int?roomId, string stat = "") { var room = _RoomService.GetById(roomId.Value); NotifictationDto dto = new NotifictationDto(); dto.senderId = Guid.Parse(User.Identity.GetUserId()); dto.RevieverId = _RoomService.getMangerIdForRoom(roomId.Value); var s1 = "الغرفة رقم"; var s2 = room.RoomNum; var s3 = " بحاجة الى "; var s6 = "تنظيف"; var s7 = "صيانة"; if (stat.Contains("صيانة")) { dto.NotText = s1 + s2 + s3 + s7; } if (stat.Contains("تنظيف")) { dto.NotText = s1 + s2 + s3 + s6; } dto.NotDateTime = DateTimeHelper.ConvertDateToString(Utils.ServerNow.Date, DateFormats.DD_MM_YYYY); dto.Room_ID = roomId; _notifictationService.Add(dto); dto = new NotifictationDto(); return(RedirectToAction("NotificationsView")); }
public bool Edit(NotifictationDto dto) { Notifictation n = _unitOfWork.NotifictationRepository.FindById(dto.Id); n.IsRead = dto.IsRead; _unitOfWork.NotifictationRepository.Update(n); _unitOfWork.SaveChanges(); return(true); }
public int Add(NotifictationDto dto) { Notifictation n = new Notifictation(); n.senderId = dto.senderId.Value; n.RevieverId = dto.RevieverId.Value; n.NotText = dto.NotText; n.NotDateTime = dto.NotDateTime; if (dto.Room_ID.HasValue) { n.Room_ID = dto.Room_ID; } if (dto.Equipment_ID.HasValue) { n.Equipment_ID = dto.Equipment_ID; } _unitOfWork.NotifictationRepository.Add(n); _unitOfWork.SaveChanges(); return(n.Id); }