public bool AddNewSendToRepair(Tbl_SendToRepair tu) { try { if (tu.Request_ID != 0) { // user already exists Tbl_SendToRepair ToBeUpdatedSendToRepair = _context.Tbl_SendToRepair.First(x => x.Request_ID == tu.Request_ID); ToBeUpdatedSendToRepair.Customer_ID = tu.Customer_ID; ToBeUpdatedSendToRepair.CustomerConnector = tu.CustomerConnector; ToBeUpdatedSendToRepair.DeviceSerialNumber = tu.DeviceSerialNumber; ToBeUpdatedSendToRepair.DeliveryDate = tu.DeliveryDate; ToBeUpdatedSendToRepair.WarrantyPeriod = tu.WarrantyPeriod; ToBeUpdatedSendToRepair.ProblemInfo = tu.ProblemInfo; ToBeUpdatedSendToRepair.PostageDate = tu.PostageDate; ToBeUpdatedSendToRepair.ReturnDate = tu.ReturnDate; ToBeUpdatedSendToRepair.Description = tu.Description; ToBeUpdatedSendToRepair.LastUpdateDate = tu.LastUpdateDate; ToBeUpdatedSendToRepair.LastUpdateTime = tu.LastUpdateTime; ToBeUpdatedSendToRepair.LastUpdateUser_ID = tu.LastUpdateUser_ID; } else { Tbl_SendToRepair ToBeInsertedSendToRepair = new Tbl_SendToRepair(); ToBeInsertedSendToRepair.Customer_ID = tu.Customer_ID; ToBeInsertedSendToRepair.CustomerConnector = tu.CustomerConnector; ToBeInsertedSendToRepair.DeviceSerialNumber = tu.DeviceSerialNumber; ToBeInsertedSendToRepair.DeliveryDate = tu.DeliveryDate; ToBeInsertedSendToRepair.WarrantyPeriod = tu.WarrantyPeriod; ToBeInsertedSendToRepair.ProblemInfo = tu.ProblemInfo; ToBeInsertedSendToRepair.PostageDate = tu.PostageDate; ToBeInsertedSendToRepair.ReturnDate = tu.ReturnDate; ToBeInsertedSendToRepair.Description = tu.Description; ToBeInsertedSendToRepair.LastUpdateDate = tu.LastUpdateDate; ToBeInsertedSendToRepair.LastUpdateTime = tu.LastUpdateTime; ToBeInsertedSendToRepair.LastUpdateUser_ID = tu.LastUpdateUser_ID; _context.Tbl_SendToRepair.Add(ToBeInsertedSendToRepair); } if (_context.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public ActionResult SubmitSendToRepair(SendToRepairModel model) { HttpSessionStateBase session = HttpContext.Session; try { Tbl_SendToRepair tu = new Tbl_SendToRepair(); tu.Customer_ID = model.Customer_ID; tu.CustomerConnector = model.CustomerConnector; tu.DeviceSerialNumber = model.Reserve; tu.DeliveryDate = model.DeliveryDate; tu.WarrantyPeriod = model.WarrantyPeriod; tu.ProblemInfo = model.ProblemInfo; tu.PostageDate = model.PostageDate; tu.ReturnDate = model.ReturnDate; tu.Description = model.Description; tu.Request_ID = model.Request_ID; tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]); tu.LastUpdateDate = DateTime.Now.ToString("yyyy-MM-dd"); tu.LastUpdateTime = DateTime.Now.ToString("HH:mm"); if (_hardwareService.AddNewSendToRepair(tu)) { var gridModel = new DataSourceResult { ExtraData = new SendToRepairModel { Message = Message.OperationSuccessful, MessageColor = "green" }, Total = 1 }; return Json(gridModel); } else { var gridModel = new DataSourceResult { ExtraData = new SendToRepairModel { Message = Message.OperationUnsuccessful, MessageColor = "red" }, Total = 1 }; return Json(gridModel); } } catch (Exception ex) { var gridModel = new DataSourceResult { ExtraData = new SendToRepairModel { Message = Message.OperationUnsuccessful, MessageColor = "red" }, Total = 1 }; return Json(gridModel); } //return ""; }