Example #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,EmployeeName,FatherName,Gender,NRC,Nationality,MartialStatus,DateOfBirth,MobilePhone,CurrentAddress,EmergencyNo,AccountNo,ATMNumber,IsActive,CreatedDate,CreatedBy,EmployeeProfile,BranchId,DepartmentId,DesignationId")] EmployeeInfo employeeInfo)
        {
            if (id != employeeInfo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await employeeInfoRepository.Update(employeeInfo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeInfoExists(employeeInfo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BranchId"]      = new SelectList(branchRepository.GetBranchList(), "Id", "Id", employeeInfo.BranchId);
            ViewData["DepartmentId"]  = new SelectList(departmentRepository.GetDepartmentList(), "Id", "Id", employeeInfo.DepartmentId);
            ViewData["DesignationId"] = new SelectList(designationRepository.GetDesignationList(), "Id", "Id", employeeInfo.DesignationId);
            return(View(employeeInfo));
        }
 public static void Update(employee_info obj)
 {
     repository.Update(obj);
 }
Example #3
0
        public virtual ActionResult Edit(EmployeeInfoViewModel viewModel)
        {
            //validate birthdate
            if (!viewModel.EmployeeInfo.Employee.BirthDate.IsValidBirthDate())
            {
                GetDropDowns(viewModel, viewModel.EmployeeInfo.EmployeeId);
                ModelState.AddModelError("", ErrorMessages.INVALID_DATE);
                return(View("Details", viewModel));
            }

            var employeeInfo = _employeeInfoRepository.GetById(viewModel.EmployeeInfo.EmploymentInfoId);

            _employeeInfoRepository.Update(employeeInfo);

            employeeInfo.Allowance        = viewModel.EmployeeInfo.Allowance;
            employeeInfo.CustomDate1      = viewModel.EmployeeInfo.CustomDate1;
            employeeInfo.DateHired        = viewModel.EmployeeInfo.DateHired;
            employeeInfo.Dependents       = viewModel.EmployeeInfo.Dependents;
            employeeInfo.EmploymentStatus = viewModel.EmployeeInfo.EmploymentStatus;
            employeeInfo.GSIS             = viewModel.EmployeeInfo.GSIS;
            employeeInfo.Married          = viewModel.EmployeeInfo.Married;
            employeeInfo.PAGIBIG          = viewModel.EmployeeInfo.PAGIBIG;
            employeeInfo.EmploymentStatus = viewModel.EmployeeInfo.EmploymentStatus;
            employeeInfo.PhilHealth       = viewModel.EmployeeInfo.PhilHealth;
            employeeInfo.SSS              = viewModel.EmployeeInfo.SSS;
            employeeInfo.Salary           = viewModel.EmployeeInfo.Salary;
            employeeInfo.TIN              = viewModel.EmployeeInfo.TIN;
            employeeInfo.EmploymentStatus = viewModel.EmploymentStatus;

            employeeInfo.PositionId      = viewModel.PositionId;
            employeeInfo.SalaryFrequency = (FrequencyType)viewModel.PaymentFrequency;
            var picture = employeeInfo.Employee.Picture;

            employeeInfo.Employee.InjectFrom(viewModel.EmployeeInfo.Employee);
            employeeInfo.Employee.Gender  = viewModel.Gender;
            employeeInfo.Employee.Picture = picture;

            var employeeDeductions = viewModel.CheckedEmployeeDeductions != null
                                    ? JsonConvert.DeserializeObject <List <EmployeeDeduction> >(viewModel.CheckedEmployeeDeductions)
                                    : new List <EmployeeDeduction>();

            _employeeDeductionService.UpdateEmployeeDeduction(employeeDeductions, viewModel.EmployeeInfo.EmployeeId);

            var departments = viewModel.CheckedDepartments != null
                            ? viewModel.CheckedDepartments.Split(',').Select(Int32.Parse)
                            : new List <int>();

            //work schedules
            _employeeWorkScheduleService.Update(viewModel.WorkScheduleId, viewModel.EmployeeInfo.EmployeeId);

            _employeeRepository.UpdateDepartment(departments, viewModel.EmployeeInfo.EmployeeId);
            _employeeInfoHistoryRepository.Add(employeeInfo.MapItem <EmployeeInfoHistory>());
            _unitOfWork.Commit();

            //upload the picture and update the record
            var imagePath = UploadImage(viewModel.EmployeeInfo.EmployeeId);

            if (!String.IsNullOrEmpty(imagePath))
            {
                var employee = employeeInfo.Employee;
                _employeeRepository.Update(employee);
                employee.Picture = imagePath;
                _unitOfWork.Commit();
            }

            _logger.Info(LoggerMessages.INFO_USER_UPDATE, employeeInfo.EmployeeId, User.Identity.GetUserId());
            return(RedirectToAction("Index"));
        }