private void ConvertToTWork(TWorkViewModel vm, TWork entity, string ParentProjectId)
 {
     entity.WorkQty             = vm.WorkQty;
     entity.WorkPrice           = vm.WorkPrice;
     entity.WorkTotal           = vm.WorkQty * vm.WorkPrice;
     entity.WorkRealQty         = vm.WorkRealQty;
     entity.WorkRealPaid        = vm.WorkRealPaid;
     entity.JobId               = string.IsNullOrEmpty(vm.JobId) ? null : _jobTasks.One(vm.JobId);
     entity.ProjectId           = string.IsNullOrEmpty(ParentProjectId) ? null : _tasks.One(ParentProjectId);
     entity.WorkRetentionStatus = vm.WorkRetentionStatus;
 }
 public ActionResult TWorks_Destroy([DataSourceRequest] DataSourceRequest request, TWorkViewModel vm, string ParentProjectId)
 {
     if (vm != null)
     {
         var entity = _workTasks.One(vm.WorkId);
         if (entity != null)
         {
             entity.ModifiedDate = DateTime.Now;
             entity.ModifiedBy   = User.Identity.Name;
             entity.DataStatus   = "Deleted";
             _workTasks.Update(entity);
         }
     }
     return(Json(ModelState.ToDataSourceResult()));
 }
        public ActionResult TWorks_Create([DataSourceRequest] DataSourceRequest request, TWorkViewModel vm, string ParentProjectId)
        {
            if (vm != null && ModelState.IsValid)
            {
                TWork entity = new TWork();
                entity.SetAssignedIdTo(Guid.NewGuid().ToString());

                ConvertToTWork(vm, entity, ParentProjectId);

                entity.CreatedDate = DateTime.Now;
                entity.CreatedBy   = User.Identity.Name;
                entity.DataStatus  = "New";

                _workTasks.Insert(entity);
            }

            return(Json(new[] { vm }.ToDataSourceResult(request, ModelState)));
        }