public bool AddNewSoftwareChange(Tbl_ChangeSoftware tu) { try { if (tu.Request_ID != 0) { // user already exists Tbl_ChangeSoftware ToBeUpdatedSoftware = _context.Tbl_ChangeSoftware.First(x => x.Request_ID == tu.Request_ID); ToBeUpdatedSoftware.Amount = tu.Amount; ToBeUpdatedSoftware.CustomerConnector = tu.CustomerConnector; ToBeUpdatedSoftware.Description = tu.Description; ToBeUpdatedSoftware.LastUpdateDate = tu.LastUpdateDate; ToBeUpdatedSoftware.LastUpdateTime = tu.LastUpdateTime; ToBeUpdatedSoftware.LastUpdateUser_ID = tu.LastUpdateUser_ID; ToBeUpdatedSoftware.RequestDate = tu.RequestDate; ToBeUpdatedSoftware.Customer_ID = tu.Customer_ID; ToBeUpdatedSoftware.DeliveryDate = tu.DeliveryDate; ToBeUpdatedSoftware.RequiredChanges = tu.RequiredChanges; } else { Tbl_ChangeSoftware ToBeInsertedSoftware = new Tbl_ChangeSoftware(); ToBeInsertedSoftware.Amount = tu.Amount; ToBeInsertedSoftware.CustomerConnector = tu.CustomerConnector; ToBeInsertedSoftware.Description = tu.Description; ToBeInsertedSoftware.LastUpdateDate = tu.LastUpdateDate; ToBeInsertedSoftware.LastUpdateTime = tu.LastUpdateTime; ToBeInsertedSoftware.LastUpdateUser_ID = tu.LastUpdateUser_ID; ToBeInsertedSoftware.RequestDate = tu.RequestDate; ToBeInsertedSoftware.Customer_ID = tu.Customer_ID; ToBeInsertedSoftware.DeliveryDate = tu.DeliveryDate; ToBeInsertedSoftware.RequiredChanges = tu.RequiredChanges; _context.Tbl_ChangeSoftware.Add(ToBeInsertedSoftware); } if (_context.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public ActionResult SubmitSoftwareChange(DataSourceRequest command, ChangeSoftwareListModel model) { HttpSessionStateBase session = HttpContext.Session; try { if (false) // field validation { var gridModel = new DataSourceResult { ExtraData = new SoftwareListModel { Message = Message.InvalidCharacter, }, Total = 1 }; return(Json(gridModel)); } Tbl_ChangeSoftware tu = new Tbl_ChangeSoftware(); tu.Request_ID = model.Request_ID; tu.CustomerConnector = model.CustomerConnector; tu.Customer_ID = model.Customer_ID; tu.Description = model.Description; tu.RequestDate = model.RequestDate; tu.RequiredChanges = model.RequiredChanges; tu.DeliveryDate = model.DeliveryDate; tu.Description = model.Description; tu.Amount = model.Amount; tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]); tu.LastUpdateDate = DateTime.Now.ToString("yyyy-MM-dd"); tu.LastUpdateTime = DateTime.Now.ToString("HH:mm"); if (_softwareService.AddNewSoftwareChange(tu)) { var gridModel = new DataSourceResult { ExtraData = new ChangeSoftwareListModel { Message = Message.OperationSuccessful, MessageColor = "green", }, Total = 1 }; return(Json(gridModel)); } else { var gridModel = new DataSourceResult { ExtraData = new ChangeSoftwareListModel { Message = Message.OperationUnsuccessful, MessageColor = "red", }, Total = 1 }; return(Json(gridModel)); } } catch (Exception ex) { var gridModel = new DataSourceResult { ExtraData = new ChangeSoftwareListModel { Message = Message.OperationUnsuccessful, MessageColor = "red", }, Total = 1 }; return(Json(gridModel)); } //return ""; }