public ActionResult Create(StaffLuongGiuHopDongViewModel model)
        {
            if (ModelState.IsValid)
            {
                var StaffLuongGiuHopDong = new StaffLuongGiuHopDong();
                AutoMapper.Mapper.Map(model, StaffLuongGiuHopDong);
                StaffLuongGiuHopDong.IsDeleted      = false;
                StaffLuongGiuHopDong.CreatedUserId  = WebSecurity.CurrentUserId;
                StaffLuongGiuHopDong.ModifiedUserId = WebSecurity.CurrentUserId;
                StaffLuongGiuHopDong.AssignedUserId = WebSecurity.CurrentUserId;
                StaffLuongGiuHopDong.CreatedDate    = DateTime.Now;
                StaffLuongGiuHopDong.ModifiedDate   = DateTime.Now;
                //StaffLuongGiuHopDong.TargetMonth = DateTime.Now.Month;
                //StaffLuongGiuHopDong.TargetYear = DateTime.Now.Year;

                StaffLuongGiuHopDongRepository.InsertStaffLuongGiuHopDong(StaffLuongGiuHopDong);
                if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                {
                    return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
                }
                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public ActionResult Edit(StaffLuongGiuHopDongViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var StaffLuongGiuHopDong = StaffLuongGiuHopDongRepository.GetStaffLuongGiuHopDongById(model.Id);
                    AutoMapper.Mapper.Map(model, StaffLuongGiuHopDong);
                    StaffLuongGiuHopDong.ModifiedUserId = WebSecurity.CurrentUserId;
                    StaffLuongGiuHopDong.ModifiedDate   = DateTime.Now;
                    StaffLuongGiuHopDongRepository.UpdateStaffLuongGiuHopDong(StaffLuongGiuHopDong);
                    if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
                    {
                        return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
                    }
                    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");
        }
        public ViewResult Create(int Id)
        {
            var model = new StaffLuongGiuHopDongViewModel();

            model.StaffId = Id;

            return(View(model));
        }
        public ActionResult Detail(int?Id)
        {
            var StaffLuongGiuHopDong = StaffLuongGiuHopDongRepository.GetStaffLuongGiuHopDongById(Id.Value);

            if (StaffLuongGiuHopDong != null && StaffLuongGiuHopDong.IsDeleted != true)
            {
                var model = new StaffLuongGiuHopDongViewModel();
                AutoMapper.Mapper.Map(StaffLuongGiuHopDong, 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"));
        }