public ViewResult Create() { var model = new InternalNotificationsViewModel(); Session["file"] = null; return(View(model)); }
public ViewResult Search(string CodeStaff, string NameStaff, string Position, int?branchId, int?DepartmentId, string StaffList) { List <string> listIdStaff = new List <string>(); var model = new InternalNotificationsViewModel(); model.StaffList = StaffsRepository.GetvwAllStaffs() .Select(item => new StaffsViewModel { Id = item.Id, Name = item.Name, ProfileImage = item.ProfileImage, Code = item.Code, BranchDepartmentId = item.BranchDepartmentId, Sale_BranchId = item.Sale_BranchId, Staff_DepartmentId = item.Staff_DepartmentId, Position = item.Position, Gender = item.Gender }).ToList(); if (!string.IsNullOrEmpty(StaffList)) { listIdStaff = StaffList.Split(',').ToList(); model.StaffList = model.StaffList.Where(id1 => !listIdStaff.Any(id2 => id2 == id1.Id.ToString())).ToList(); } if (!string.IsNullOrEmpty(CodeStaff)) { model.StaffList = model.StaffList.Where(item => Erp.BackOffice.Helpers.Common.ChuyenThanhKhongDau(item.Code).ToLower().Contains(Erp.BackOffice.Helpers.Common.ChuyenThanhKhongDau(CodeStaff).ToLower())); } if (!string.IsNullOrEmpty(NameStaff)) { model.StaffList = model.StaffList.Where(item => Erp.BackOffice.Helpers.Common.ChuyenThanhKhongDau(item.Name).ToLower().Contains(Erp.BackOffice.Helpers.Common.ChuyenThanhKhongDau(NameStaff).ToLower())); } if (!string.IsNullOrEmpty(Position)) { model.StaffList = model.StaffList.Where(item => item.Position == Position); } if (branchId != null && branchId.Value > 0) { model.StaffList = model.StaffList.Where(item => item.Sale_BranchId == branchId); } if (DepartmentId != null && DepartmentId.Value > 0) { model.StaffList = model.StaffList.Where(item => item.BranchDepartmentId == DepartmentId); } var user = userRepository.GetUserById(WebSecurity.CurrentUserId); if (user.UserTypeId == 1) { model.StaffList = model.StaffList.OrderBy(m => m.Name); } else { model.StaffList = model.StaffList.Where(x => x.Sale_BranchId == user.BranchId).OrderBy(m => m.Name); } return(View(model)); }
public ActionResult Create(InternalNotificationsViewModel model) { var q = Request["staffListcancel"]; if (ModelState.IsValid) { var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var Notification = new Domain.Staff.Entities.InternalNotifications(); Notification.IsDeleted = false; Notification.CreatedUserId = WebSecurity.CurrentUserId; Notification.ModifiedUserId = WebSecurity.CurrentUserId; Notification.CreatedDate = DateTime.Now; Notification.ModifiedDate = DateTime.Now; Notification.Titles = model.Titles; Notification.Type = "notifications"; Notification.Content = model.Content; Notification.PlaceOfNotice = WebSecurity.CurrentUserId.ToString(); Notification.PlaceOfReceipt = q; Notification.Disable = false; Notification.Seen = false; Notification.ModuleName = "InternalNotifications"; Notification.ActionName = "NotificationsDetail"; InternalNotificationsRepository.InsertInternalNotifications(Notification); Erp.BackOffice.Staff.Controllers.DocumentFieldController.SaveUpload(Notification.Titles, q, Notification.Id, "InternalNotifications"); var ProfileImage = ""; var Name = user.FullName; var path = Helpers.Common.GetSetting("Staff"); if (string.IsNullOrEmpty(user.ProfileImage)) { ProfileImage = "/assets/img/no-avatar.png"; } else { ProfileImage = path + user.ProfileImage; } return(Json(new { id = Notification.Id, message = Erp.BackOffice.Hubs.ErpHub.Contentmessage(Notification.Id, Notification.Id, ProfileImage, Notification.Titles, Name, Notification.CreatedDate, Notification.ActionName, Notification.ModuleName) })); } Session["file"] = null; return(View(model)); }
public ActionResult Edit(int?Id) { var InternalNotifications = InternalNotificationsRepository.GetInternalNotificationsById(Id.Value); if (InternalNotifications != null && InternalNotifications.IsDeleted != true) { var model = new InternalNotificationsViewModel(); AutoMapper.Mapper.Map(InternalNotifications, model); //if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) //{ // TempData["FailedMessage"] = "NotOwner"; // return RedirectToAction("Index"); //} return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ViewResult NotificationsDetail(int?NotificationsId) { var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var staff = Erp.BackOffice.Helpers.Common.GetStaffByCurrentUser(); var notifications = InternalNotificationsRepository.GetvwInternalNotificationsById(NotificationsId.Value); var model = new InternalNotificationsViewModel(); AutoMapper.Mapper.Map(notifications, model); var staffCreateNotifications = StaffsRepository.GetvwStaffsByUser(model.CreatedUserId.Value); if (staffCreateNotifications != null) { ViewBag.Staff = staffCreateNotifications; } else { ViewBag.Staff = null; } model.NotificationsDetailList = notificationsRepository.GetAllvwNotificationsDetailbyId(NotificationsId) .Select(item => new NotificationsDetailViewModel { Id = item.Id, CreatedUserId = item.CreatedUserId, //CreatedUserName = item.CreatedUserName, CreatedDate = item.CreatedDate, ModifiedUserId = item.ModifiedUserId, //ModifiedUserName = item.ModifiedUserName, ModifiedDate = item.ModifiedDate, Code = item.Code, Comment = item.Comment, Gender = item.Gender, Name = item.Name, ProfileImage = item.ProfileImage, StaffId = item.StaffId }).OrderByDescending(x => x.ModifiedDate); return(View(model)); }
public ActionResult Edit(InternalNotificationsViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var q = Request["staffListcancel"]; var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var InternalNotifications = InternalNotificationsRepository.GetInternalNotificationsById(model.Id); AutoMapper.Mapper.Map(model, InternalNotifications); InternalNotifications.ModifiedUserId = WebSecurity.CurrentUserId; InternalNotifications.ModifiedDate = DateTime.Now; InternalNotifications.PlaceOfReceipt = q; InternalNotificationsRepository.UpdateInternalNotifications(InternalNotifications); //cập nhật lại phân quyền ở trang lưu trữ tài liệu. Erp.BackOffice.Staff.Controllers.DocumentFieldController.UpdateStaff(q, model.Id, "InternalNotifications"); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess; //return Json(new { id = InternalNotifications.Id, message = "<li id=\"notifications_item_" + InternalNotifications.Id + "\"><a style=\"color:red !important\" href=\"/InternalNotifications/Edit/?Id=" + InternalNotifications.Id + "\"><b>" + user.FullName + " " + string.Format("Cập nhật \"{0}\" lúc {1}", InternalNotifications.Titles, InternalNotifications.ModifiedDate.Value.ToString("HH:mm - dd/MM/yyyy")) + "</b></a></li>" }); var staff = Helpers.Common.GetStaffByCurrentUser(); var ProfileImage = ""; var Name = ""; if (staff.Name == null) { Name = user.FullName; } else { Name = staff.Name; } if (string.IsNullOrEmpty(staff.ProfileImage)) { ProfileImage = "/assets/img/no-avatar.png"; } else { ProfileImage = "/Data/HinhSV/" + staff.ProfileImage; } return(Json(new { id = InternalNotifications.Id, StaffId = InternalNotifications.PlaceOfReceipt, message = "<li id=\"notifications_item_" + InternalNotifications.Id + "\"><a style=\"color:red !important\" href=\"/InternalNotifications/NotificationsDetail/?NotificationsId=" + InternalNotifications.Id + "\"><img style=\"max-height: 47px;min-width:42px\" src=\"" + ProfileImage + "\"class=\"msg-photo\"><span class=\"msg-body\"><span class=\"msg-title\"><span class=\"blue\"><b>" + Name + "</b></span>cập nhật:" + InternalNotifications.Titles + "...</span><span class=\"msg-time\"><i class=\"ace-icon fa fa-clock-o\"></i> " + InternalNotifications.ModifiedDate.Value.ToString("HH:mm dd/MM/yyyy") + "</span></span></a></li>" })); } return(RedirectToAction("Edit", new { Id = model.Id })); } return(View(model)); //if (Request.UrlReferrer != null) // return Redirect(Request.UrlReferrer.AbsoluteUri); //return RedirectToAction("Index"); }