//[AcceptVerbs(HttpVerbs.Post)] //public ActionResult TAbsentDets_Create([DataSourceRequest] DataSourceRequest request, TAbsentDetViewModel vm, string ParentAbsentId) //{ // if (vm != null && ModelState.IsValid) // { // TAbsentDet entity = new TAbsentDet(); // entity.SetAssignedIdTo(Guid.NewGuid().ToString()); // ConvertToTAbsentDet(vm, entity,ParentAbsentId); // entity.CreatedDate = DateTime.Now; // entity.CreatedBy = User.Identity.Name; // entity.DataStatus = "New"; // _absentDetTasks.Insert(entity); // } // return Json(new[] { vm }.ToDataSourceResult(request, ModelState)); //} private void ConvertToTAbsentDet(TAbsentDetViewModel vm, TAbsentDet entity, string ParentAbsentId) { //date is read only //entity.AbsentDetDate = vm.AbsentDetDate; entity.AbsentDetStart = vm.AbsentDetStart; entity.AbsentDetEnd = vm.AbsentDetEnd; entity.AbsentDetQty = vm.AbsentDetEnd - vm.AbsentDetStart; entity.AbsentDetBlock = vm.AbsentDetBlock; entity.AbsentDetResult = vm.AbsentDetResult; entity.AbsentDetBbm = vm.AbsentDetBbm; entity.AbsentDetDesc = vm.AbsentDetDesc; entity.AbsentId = string.IsNullOrEmpty(ParentAbsentId) ? null : _absentTasks.One(ParentAbsentId); entity.AbsentDetOperator = string.IsNullOrEmpty(vm.AbsentDetOperator) ? null : _employeeTasks.One(vm.AbsentDetOperator); entity.AbsentDetSinso = string.IsNullOrEmpty(vm.AbsentDetSinso) ? null : _employeeTasks.One(vm.AbsentDetSinso); entity.WorkId = string.IsNullOrEmpty(vm.WorkId) ? null : _TWorkTasks.One(vm.WorkId); }
public ActionResult TAbsentDets_Update([DataSourceRequest] DataSourceRequest request, TAbsentDetViewModel vm, string ParentAbsentId) { if (vm != null && ModelState.IsValid) { var entity = _absentDetTasks.One(vm.AbsentDetId); if (entity != null) { ConvertToTAbsentDet(vm, entity, ParentAbsentId); entity.ModifiedDate = DateTime.Now; entity.ModifiedBy = User.Identity.Name; entity.DataStatus = "Updated"; _absentDetTasks.Update(entity); //calculate total CalculateTotalAbsent(ParentAbsentId, entity.AbsentId); } } return(Json(ModelState.ToDataSourceResult())); }