public ViewResult Create(int Id)
        {
            var model = new StaffAllowanceViewModel();

            model.StaffId = Id;
            return(View(model));
        }
        public ActionResult Edit(StaffAllowanceViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var StaffAllowance = StaffAllowanceRepository.GetStaffAllowanceById(model.Id);
                    AutoMapper.Mapper.Map(model, StaffAllowance);
                    StaffAllowance.ModifiedUserId = WebSecurity.CurrentUserId;
                    StaffAllowance.ModifiedDate   = DateTime.Now;
                    StaffAllowanceRepository.UpdateStaffAllowance(StaffAllowance);
                    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 ActionResult Edit(int?Id)
        {
            var StaffAllowance = StaffAllowanceRepository.GetStaffAllowanceById(Id.Value);

            if (StaffAllowance != null && StaffAllowance.IsDeleted != true)
            {
                var model = new StaffAllowanceViewModel();
                AutoMapper.Mapper.Map(StaffAllowance, 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 ActionResult Create(StaffAllowanceViewModel model)
 {
     if (ModelState.IsValid)
     {
         var StaffAllowance = new StaffAllowance();
         AutoMapper.Mapper.Map(model, StaffAllowance);
         StaffAllowance.IsDeleted      = false;
         StaffAllowance.CreatedUserId  = WebSecurity.CurrentUserId;
         StaffAllowance.ModifiedUserId = WebSecurity.CurrentUserId;
         StaffAllowance.AssignedUserId = WebSecurity.CurrentUserId;
         StaffAllowance.CreatedDate    = DateTime.Now;
         StaffAllowance.ModifiedDate   = DateTime.Now;
         //StaffAllowance.TargetMonth = DateTime.Now.Month;
         //StaffAllowance.TargetYear = DateTime.Now.Year;
         StaffAllowanceRepository.InsertStaffAllowance(StaffAllowance);
         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));
 }