public ActionResult TSalarys_Create([DataSourceRequest] DataSourceRequest request, TSalaryViewModel vm) { if (vm != null && ModelState.IsValid) { TSalary entity = new TSalary(); entity.SetAssignedIdTo(Guid.NewGuid().ToString()); ConvertToTSalary(vm, entity); entity.CreatedDate = DateTime.Now; entity.CreatedBy = User.Identity.Name; entity.DataStatus = EnumDataStatus.New.ToString(); _tasks.Insert(entity); } return(Json(new[] { vm }.ToDataSourceResult(request, ModelState))); }
private void ConvertToTSalary(TSalaryViewModel vm, TSalary entity) { MEmployee emp = string.IsNullOrEmpty(vm.EmployeeId) ? null : _MEmployeeTasks.One(vm.EmployeeId); entity.EmployeeId = emp; entity.ProjectId = string.IsNullOrEmpty(vm.ProjectId) ? null : _TProjectTasks.One(vm.ProjectId); entity.SalaryPeriod = new DateTime(vm.SalaryPeriod.Value.Year, vm.SalaryPeriod.Value.Month, 1); if (emp != null) { entity.SalaryGapok = emp.EmployeeBasicSalary; entity.SalaryWorkQty = _absenDetTasks.GetTotalQtyByEmp(emp.Id, entity.SalaryPeriod); entity.SalaryWorkTotal = emp.EmployeeDailyAllowance * entity.SalaryWorkQty; entity.SalaryTotal = entity.SalaryGapok + entity.SalaryWorkTotal; } //entity.SalaryStatus = vm.SalaryStatus; //entity.SalaryDesc = vm.SalaryDesc; }