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;
        }
        public ActionResult TSalarys_Update([DataSourceRequest] DataSourceRequest request, TSalaryViewModel vm)
        {
            if (vm != null && ModelState.IsValid)
            {
                var entity = _tasks.One(vm.SalaryId);
                if (entity != null)
                {
                    ConvertToTSalary(vm, entity);

                    entity.ModifiedDate = DateTime.Now;
                    entity.ModifiedBy   = User.Identity.Name;
                    entity.DataStatus   = EnumDataStatus.Updated.ToString();

                    _tasks.Update(entity);
                }
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
        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)));
        }