예제 #1
0
 public bool AddNewDeviceFailure(Tbl_DeviceFailure tu)
 {
     try
     {
         if (tu.Request_ID != 0)
         {
             // user already exists
             Tbl_DeviceFailure ToBeUpdatedDeviceFailure = _context.Tbl_DeviceFailure.First(x => x.Request_ID == tu.Request_ID);
             ToBeUpdatedDeviceFailure.CustomerConnector          = tu.CustomerConnector;
             ToBeUpdatedDeviceFailure.Description                = tu.Description;
             ToBeUpdatedDeviceFailure.ProblemType                = tu.ProblemType;
             ToBeUpdatedDeviceFailure.LastUpdateDate             = tu.LastUpdateDate;
             ToBeUpdatedDeviceFailure.LastUpdateTime             = tu.LastUpdateTime;
             ToBeUpdatedDeviceFailure.LastUpdateUser_ID          = tu.LastUpdateUser_ID;
             ToBeUpdatedDeviceFailure.RequestDate                = tu.RequestDate;
             ToBeUpdatedDeviceFailure.Troubleshooting            = tu.Troubleshooting;
             ToBeUpdatedDeviceFailure.Customer_ID                = tu.Customer_ID;
             ToBeUpdatedDeviceFailure.WarrantyPeriod             = tu.WarrantyPeriod;
             ToBeUpdatedDeviceFailure.DeliveryDate               = tu.DeliveryDate;
             ToBeUpdatedDeviceFailure.DeliveryDeviceSerialNumber = tu.DeliveryDeviceSerialNumber;
         }
         else
         {
             Tbl_DeviceFailure ToBeInsertedDeviceFailure = new Tbl_DeviceFailure();
             ToBeInsertedDeviceFailure.CustomerConnector          = tu.CustomerConnector;
             ToBeInsertedDeviceFailure.Description                = tu.Description;
             ToBeInsertedDeviceFailure.ProblemType                = tu.ProblemType;
             ToBeInsertedDeviceFailure.LastUpdateDate             = tu.LastUpdateDate;
             ToBeInsertedDeviceFailure.LastUpdateTime             = tu.LastUpdateTime;
             ToBeInsertedDeviceFailure.LastUpdateUser_ID          = tu.LastUpdateUser_ID;
             ToBeInsertedDeviceFailure.RequestDate                = tu.RequestDate;
             ToBeInsertedDeviceFailure.Customer_ID                = tu.Customer_ID;
             ToBeInsertedDeviceFailure.Troubleshooting            = tu.Troubleshooting;
             ToBeInsertedDeviceFailure.WarrantyPeriod             = tu.WarrantyPeriod;
             ToBeInsertedDeviceFailure.DeliveryDate               = tu.DeliveryDate;
             ToBeInsertedDeviceFailure.DeliveryDeviceSerialNumber = tu.DeliveryDeviceSerialNumber;
             _context.Tbl_DeviceFailure.Add(ToBeInsertedDeviceFailure);
         }
         if (_context.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #2
0
        public ActionResult SubmitDeviceFailure(DeviceFailureModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;
            try
            {

                Tbl_DeviceFailure tu = new Tbl_DeviceFailure();
                tu.CustomerConnector = model.CustomerConnector;
                tu.Customer_ID = model.Customer_ID;
                tu.Description = model.Description;
                tu.ProblemType = model.ProblemType_ID;
                tu.RequestDate = model.RequestDate;
                tu.DeliveryDate = model.DeliveryDate;
                tu.Request_ID = model.Request_ID;
                tu.DeliveryDeviceSerialNumber = model.Reserve;//.DeliveryDeviceSerialNumber;
                tu.WarrantyPeriod = model.WarrantyPeriod;
                tu.Troubleshooting = model.TroubleShooting_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.AddNewDeviceFailure(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new DeviceFailureModel
                        {
                            Message = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new DeviceFailureModel
                        {
                            Message = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }

            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new DeviceFailureModel
                    {
                        Message = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return Json(gridModel);
            }
            //return "";
        }