public ActionResult Edit(Guid?Id)
        {
            EmployeeSalaryDetail retriveEmployeeSalaryDetail = db.EmployeeSalaryDetails.Where(es => es.ContactId == Id).FirstOrDefault();

            if (retriveEmployeeSalaryDetail == null)
            {
                EmployeeSalaryDetail          employeeSalaryDetail = new EmployeeSalaryDetail();
                EmployeeSalaryDetailViewModel empSalViewModel      = Mapper.Map <EmployeeSalaryDetailViewModel>(employeeSalaryDetail);
                empSalViewModel.EmployeeId = Id;
                return(View("Create", empSalViewModel));
            }

            EmployeeSalaryDetailViewModel viewModel = new EmployeeSalaryDetailViewModel();

            viewModel.Id                  = retriveEmployeeSalaryDetail.Id;
            viewModel.RatePerHour         = retriveEmployeeSalaryDetail.RatePerHour;
            viewModel.RatePerHourOvertime = retriveEmployeeSalaryDetail.RatePerHourOvertime;
            viewModel.EmployeeId          = retriveEmployeeSalaryDetail.ContactId;
            viewModel.PF                  = retriveEmployeeSalaryDetail.PF;
            viewModel.ESI                 = retriveEmployeeSalaryDetail.ESI;
            viewModel.Enrolled            = retriveEmployeeSalaryDetail.Enrolled;
            if (retriveEmployeeSalaryDetail.OverTimeCal == null)
            {
                retriveEmployeeSalaryDetail.OverTimeCal = null;
            }
            else
            {
                var dt = TimeSpan.Parse(retriveEmployeeSalaryDetail.OverTimeCal);
                viewModel.OverTimeCal = dt;
            }

            return(RedirectToAction("EditSave", viewModel));
        }
 public ActionResult Create(EmployeeSalaryDetailViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         EmployeeSalaryDetail employeeSalaryDetail = new EmployeeSalaryDetail();
         employeeSalaryDetail.Id                  = viewModel.Id;
         employeeSalaryDetail.RatePerHour         = viewModel.RatePerHour;
         employeeSalaryDetail.RatePerHourOvertime = viewModel.RatePerHourOvertime;
         employeeSalaryDetail.ContactId           = viewModel.EmployeeId;
         employeeSalaryDetail.PF                  = viewModel.PF;
         employeeSalaryDetail.ESI                 = viewModel.ESI;
         employeeSalaryDetail.Enrolled            = viewModel.Enrolled;
         if (viewModel.OverTimeCal == null)
         {
             employeeSalaryDetail.OverTimeCal = null;
         }
         else
         {
             employeeSalaryDetail.OverTimeCal = viewModel.OverTimeCal.Value.ToString();
         }
         db.EmployeeSalaryDetails.Add(employeeSalaryDetail);
         db.SaveChanges();
         TempData["MessageToClientSuccess"] = "Succesfully Saved Employee Salary Detail";
         return(RedirectToAction("Index", "Employees"));
     }
     return(View(viewModel));
 }
 public ActionResult Edit(EmployeeSalaryDetailViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             EmployeeSalaryDetail employeeSalaryDetail = Mapper.Map <EmployeeSalaryDetail>(viewModel);
             db.Entry(employeeSalaryDetail).State = EntityState.Modified;
             db.SaveChanges();
             TempData["MessageToClientSuccess"] = "Succesfully Updated Employee Salary Detail";
             return(RedirectToAction("Index", "Employees"));
         }
         catch (Exception ex)
         {
             // Log4NetHelper.Log(String.Format("Cannot Create Deparment {0} ", viewModel.Id), LogLevel.ERROR, "Department", viewModel.Id, User.Identity.Name, ex);
             var msg = ex.Message;
             TempData["MessageToClientError"] = msg;
         }
     }
     // ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FirstName", employeeSalaryDetail.EmployeeId);
     return(View(viewModel));
 }
        public ActionResult EditSave(EmployeeSalaryDetailViewModel viewModel)
        {
            EmployeeSalaryDetail employeeSalaryDetail = Mapper.Map <EmployeeSalaryDetail>(viewModel);

            return(View("EditSave", viewModel));
        }
Ejemplo n.º 5
0
 public LoadEmployeeSalaryDetailSuccessAction(EmployeeSalaryDetailViewModel salaryDetail) =>