コード例 #1
0
        public ActionResult Create(DotGQCDBHXHViewModel model)
        {
            if (ModelState.IsValid)
            {
                var itemp = DotGQCDBHXHRepository.GetAllDotGQCDBHXH().Where(item => item.BatchNumber == model.BatchNumber && item.Month == model.Month && item.Year == model.Year).ToList();
                if (itemp.Count() > 0)
                {
                    TempData[Globals.FailedMessageKey] = "Đã tạo đợt " + model.BatchNumber + " tháng " + model.Month + " năm " + model.Year;
                    return(RedirectToAction("Index"));
                }
                var DotQGCDBHXH = new DotGQCDBHXH();
                AutoMapper.Mapper.Map(model, DotQGCDBHXH);
                DotQGCDBHXH.IsDeleted      = false;
                DotQGCDBHXH.CreatedUserId  = WebSecurity.CurrentUserId;
                DotQGCDBHXH.ModifiedUserId = WebSecurity.CurrentUserId;
                DotQGCDBHXH.AssignedUserId = WebSecurity.CurrentUserId;
                DotQGCDBHXH.CreatedDate    = DateTime.Now;
                DotQGCDBHXH.ModifiedDate   = DateTime.Now;
                DotGQCDBHXHRepository.InsertDotGQCDBHXH(DotQGCDBHXH);

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
コード例 #2
0
        public ActionResult Detail(int?Id)
        {
            var DotQGCDBHXH = DotGQCDBHXHRepository.GetDotGQCDBHXHById(Id.Value);
            var detail      = DotGQCDBHXHDetailRepository.GetAllvwDotGQCDBHXHDetail().Where(u => u.DotGQCDBHXHId == DotQGCDBHXH.Id).ToList();

            if (DotQGCDBHXH != null && DotQGCDBHXH.IsDeleted != true)
            {
                var model = new DotGQCDBHXHViewModel();
                model.ListDotGQCDBHXHDetail = new List <DotGQCDBHXHDetailViewModel>();
                AutoMapper.Mapper.Map(DotQGCDBHXH, model);
                foreach (var item in detail)
                {
                    var detailModel = new DotGQCDBHXHDetailViewModel();
                    AutoMapper.Mapper.Map(item, detailModel);
                    model.ListDotGQCDBHXHDetail.Add(detailModel);
                }

                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"));
        }
コード例 #3
0
        public ActionResult Edit(DotGQCDBHXHViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var DotQGCDBHXH = DotGQCDBHXHRepository.GetDotGQCDBHXHById(model.Id);
                    AutoMapper.Mapper.Map(model, DotQGCDBHXH);
                    DotQGCDBHXH.ModifiedUserId = WebSecurity.CurrentUserId;
                    DotQGCDBHXH.ModifiedDate   = DateTime.Now;
                    DotGQCDBHXHRepository.UpdateDotGQCDBHXH(DotQGCDBHXH);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
コード例 #4
0
        public ViewResult Create()
        {
            var model = new DotGQCDBHXHViewModel();

            model.Name  = "Danh sách đề nghi giải quyết BHXH";
            model.Month = DateTime.Now.Month;
            model.Year  = DateTime.Now.Year;
            return(View(model));
        }