Beispiel #1
0
 public bool AddNewReturnRepairedDevice(Tbl_ReturnRepairedDevice tu)
 {
     try
     {
         if (tu.Request_ID != 0)
         {
             // user already exists
             Tbl_ReturnRepairedDevice ToBeUpdatedSendToRepair = _context.Tbl_ReturnRepairedDevice.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.Repairs            = tu.Repairs;
             ToBeUpdatedSendToRepair.ReturnDate         = tu.ReturnDate;
             ToBeUpdatedSendToRepair.Description        = tu.Description;
             ToBeUpdatedSendToRepair.LastUpdateDate     = tu.LastUpdateDate;
             ToBeUpdatedSendToRepair.LastUpdateTime     = tu.LastUpdateTime;
             ToBeUpdatedSendToRepair.LastUpdateUser_ID  = tu.LastUpdateUser_ID;
         }
         else
         {
             Tbl_ReturnRepairedDevice ToBeInsertedSendToRepair = new Tbl_ReturnRepairedDevice();
             ToBeInsertedSendToRepair.Customer_ID        = tu.Customer_ID;
             ToBeInsertedSendToRepair.CustomerConnector  = tu.CustomerConnector;
             ToBeInsertedSendToRepair.DeviceSerialNumber = tu.DeviceSerialNumber;
             ToBeInsertedSendToRepair.DeliveryDate       = tu.DeliveryDate;
             ToBeInsertedSendToRepair.WarrantyPeriod     = tu.WarrantyPeriod;
             ToBeInsertedSendToRepair.Repairs            = tu.Repairs;
             ToBeInsertedSendToRepair.ReturnDate         = tu.ReturnDate;
             ToBeInsertedSendToRepair.Description        = tu.Description;
             ToBeInsertedSendToRepair.LastUpdateDate     = tu.LastUpdateDate;
             ToBeInsertedSendToRepair.LastUpdateTime     = tu.LastUpdateTime;
             ToBeInsertedSendToRepair.LastUpdateUser_ID  = tu.LastUpdateUser_ID;
             _context.Tbl_ReturnRepairedDevice.Add(ToBeInsertedSendToRepair);
         }
         if (_context.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #2
0
        public ActionResult SubmitReturnRepairedDevice(ReturnRepairedDeviceModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;
            try
            {

                Tbl_ReturnRepairedDevice tu = new Tbl_ReturnRepairedDevice();
                tu.Customer_ID = model.Customer_ID;
                tu.CustomerConnector = model.CustomerConnector;
                tu.DeviceSerialNumber = model.Reserve;
                tu.DeliveryDate = model.DeliveryDate;
                tu.WarrantyPeriod = model.WarrantyPeriod;
                tu.Repairs = model.Repairs;
                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.AddNewReturnRepairedDevice(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new ReturnRepairedDeviceModel
                        {
                            Message = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new ReturnRepairedDeviceModel
                        {
                            Message = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }

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