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