public bool UpdateTu_SoLuongHienTai(string id, ActionWithObject action) { int soluong = 0; var tu = _tuService.GetById(id); if (tu == null) { return(false); } soluong = Compute.ComputeAmountWithAction(tu.SoLuongHienTai, action); if (soluong > tu.SoLuongMax) { ViewBag.Tus = SelectListItemFromDomain.SelectListItem_Tu(_tuService.GetAll(m => m.OrderBy(t => t.Ten))); return(false); } else { tu.SoLuongHienTai = soluong; _tuService.Update(tu); return(true); } }
public void DropDowmn() { var dangs = new List <object> { GlobalConfigs.DANG_DEN, GlobalConfigs.DANG_NOIBO }; ViewBag.LoaiHoSos = SelectListItemFromDomain.SelectListItem_LoaiHoSo(_loaiHoSoService.GetAll(m => m.OrderBy(t => t.Ten))); ViewBag.NoiBanHanhs = SelectListItemFromDomain.SelectListItem_NoiBanHanh(_noiBanHanhService.GetAll(m => m.OrderBy(t => t.Ten))); ViewBag.Dangs = SelectListItemFromDomain.SelectListItem_Object(dangs); }
public ActionResult CreateOrUpdate(KeViewModel model) { var ke = string.IsNullOrEmpty(model.Id) ? new Ke { NgayCapNhat = DateTime.Now } : _keService.Get(m => m.Id == model.Id); ViewBag.Tus = SelectListItemFromDomain.SelectListItem_Tu(_tuService.GetAll(m => m.OrderBy(t => t.Ten))); var checkName = _keService.Get(m => m.Ten == model.Ten); if (checkName != null) { TempData["AlertMessage"] = "Kệ Có Cùng Tên Đã Tồn Tại"; return(View(model)); } var userId = User.Identity.GetUserId(); var cthd = "kệ: " + model.Ten; ke.Ten = model.Ten; ke.SoThuTu = model.SoThuTu; ke.SoHopToiDa = model.SoHopToiDa; ke.NamBatDau = model.NamBatDau; ke.NamKetThuc = model.NamKetThuc; ke.TinhTrang = model.TinhTrang; ke.UserId = User.Identity.GetUserId(); ke.Tuid = model.Tuid; if (string.IsNullOrEmpty(model.Id)) { ke.SoHopHienTai = 0; var result = UpdateTu_SoLuongHienTai(model.Tuid, ActionWithObject.Update); if (!result) { TempData["AlertMessage"] = "Số Lượng Kệ Trong Tủ Bạn Chọn Đã Đầy"; return(View(model)); } _keService.Insert(ke); _functionLichSuHoatDongService.Create(ActionWithObject.Create, userId, cthd); TempData["AlertMessage"] = "Tạo Mới Thành Công"; } else { _keService.Update(ke); _functionLichSuHoatDongService.Create(ActionWithObject.Update, userId, cthd); TempData["AlertMessage"] = "Cập Nhật Thành Công"; } return(RedirectToAction("Index")); }
public ActionResult CreateOrUpdate(HoSoViewModel model) { var hoSo = string.IsNullOrEmpty(model.Id) ? new HoSo { NgayCapNhat = DateTime.Now } : _hoSoService.Get(m => m.Id == model.Id); ViewBag.LoaiHoSos = SelectListItemFromDomain.SelectListItem_LoaiHoSo(_loaiHoSoService.GetAll(m => m.OrderBy(t => t.Ten))); ViewBag.TapHoSos = SelectListItemFromDomain.SelectListItem_HoSo(_hoSoService.GetAll(m => m.OrderBy(t => t.PhongLuuTru))); var checkName = _hoSoService.Get(m => m.PhongLuuTru == model.PhongLuuTru); if (checkName != null) { TempData["AlertMessage"] = "Hồ Sơ Có Cùng Phông Lưu Trữ Đã Tồn Tại"; return(View(model)); } var autoList = LocalHops(GetHops()); var userId = User.Identity.GetUserId(); var chiTietHoatDong = "hồ sơ: " + model.PhongLuuTru; hoSo.TapHoSoId = model.TapHoSoId; hoSo.PhongLuuTru = model.PhongLuuTru; hoSo.TinhTrang = EnumTinhTrang.TrongKho; hoSo.ThoiGianBaoQuan = model.ThoiGianBaoQuan; hoSo.GhiChu = model.GhiChu; hoSo.BienMucHoSo = model.BienMucHoSo; hoSo.LoaiHoSoId = model.LoaiHoSoId; hoSo.HopId = autoList.FirstOrDefault(p => p.Text == model.HopId).Id; hoSo.UserId = userId; if (string.IsNullOrEmpty(model.Id)) { _hoSoService.Insert(hoSo); _functionLichSuHoatDongService.Create(ActionWithObject.Create, userId, chiTietHoatDong); TempData["AlertMessage"] = "Tạo Mới Thành Công"; } else { _hoSoService.Update(hoSo); _functionLichSuHoatDongService.Create(ActionWithObject.Update, userId, chiTietHoatDong); TempData["AlertMessage"] = "Cập Nhật Thành Công"; } return(RedirectToAction("Index")); }
public ActionResult CreateOrUpdate(string id) { var model = new KeViewModel(); ViewBag.Tus = SelectListItemFromDomain.SelectListItem_Tu(_tuService.GetAll(m => m.OrderBy(t => t.Ten))); if (string.IsNullOrEmpty(id)) { return(View(model)); } else { var ke = _keService.Get(m => m.Id == id); model = GetKe(ke); return(View(model)); } }
public ActionResult CreateOrUpdate(string id) { var model = new HoSoViewModel(); ViewBag.LoaiHoSos = SelectListItemFromDomain.SelectListItem_LoaiHoSo(_loaiHoSoService.GetAll(m => m.OrderBy(t => t.Ten))); ViewBag.TapHoSos = SelectListItemFromDomain.SelectListItem_HoSo(_hoSoService.GetAll(m => m.OrderBy(t => t.PhongLuuTru))); if (string.IsNullOrEmpty(id)) { return(View(model)); } else { var hoSo = _hoSoService.Get(m => m.Id == id); model = GetHoSo(hoSo); return(View(model)); } }
public void DropDownList() { ViewBag.PhongBans = SelectListItemFromDomain.SelectListItem_PhongBan( _phongBanService.GetAll(m => m.OrderBy(t => t.Ten))); }