Example #1
0
        public ActionResult SuaHopDong(HopDongModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }

            var hopdong = _chonveService.GetHopDongById(model.Id);

            if (hopdong == null || hopdong.TrangThai != Core.Domain.Chonves.ENTrangThaiHopDong.Moi || hopdong.NguoiTaoID != _workContext.CurrentCustomer.Id)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("ListHopDong"));
            }

            if (ModelState.IsValid)
            {
                hopdong = model.ToEntity(hopdong);

                //var customer = _customerService.GetCustomerByEmail(model.KhachHang.Email);
                //if (customer != null && !customer.Deleted)
                //{
                //    hopdong.KhachHangID = customer.Id;
                //}

                hopdong.NgayCapNhat = DateTime.UtcNow;
                _chonveService.UpdateHopDong(hopdong);


                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("SuaHopDong", hopdong.Id));
                }
                return(RedirectToAction("ListHopDong"));
            }
            return(View(model));
        }
Example #2
0
        public ActionResult TaoHopDong(HopDongModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }
            if (ModelState.IsValid)
            {
                var hopdong = new HopDong();
                hopdong              = model.ToEntity(hopdong);
                hopdong.NguoiTaoID   = _workContext.CurrentCustomer.Id;
                hopdong.NgayTao      = DateTime.UtcNow;
                hopdong.NgayCapNhat  = null;
                hopdong.NgayHetHan   = null;
                hopdong.NgayKichHoat = null;
                hopdong.TrangThai    = Core.Domain.Chonves.ENTrangThaiHopDong.Moi;
                _chonveService.InsertHopDong(hopdong);
                return(continueEditing ? RedirectToAction("SuaHopDong", new { id = hopdong.Id }) : RedirectToAction("ListHopDong"));
            }

            return(View(model));
        }