Пример #1
0
        public ActionResult SubmitOtherRequest(OtherRequestListModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;

            try
            {
                Tbl_OtherRequest tu = new Tbl_OtherRequest();
                tu.Description       = model.Description;
                tu.Customer_ID       = model.Customer_ID;
                tu.CustomerConnector = model.CustomerConnector;
                tu.Request_ID        = model.Request_ID;
                tu.RequestType_ID    = model.RequestType_ID;
                tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]);
                tu.LastUpdateDate    = DateTime.Now.ToString("yyyy-MM-dd");
                tu.LastUpdateTime    = DateTime.Now.ToString("HH:mm");

                if (_supportService.AddNewOtherRequest(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new OtherRequestModel
                        {
                            Message      = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return(Json(gridModel));
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new OtherRequestModel
                        {
                            Message      = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return(Json(gridModel));
                }
            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new OtherRequestModel
                    {
                        Message      = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return(Json(gridModel));
            }
            //return "";
        }
Пример #2
0
 public bool AddNewOtherRequest(Tbl_OtherRequest tu)
 {
     try
     {
         if (tu.Request_ID != 0)
         {
             // user already exists
             Tbl_OtherRequest ToBeUpdatedSoftware = _context.Tbl_OtherRequest.First(x => x.Request_ID == tu.Request_ID);
             ToBeUpdatedSoftware.CustomerConnector = tu.CustomerConnector;
             ToBeUpdatedSoftware.RequestType_ID    = tu.RequestType_ID;
             ToBeUpdatedSoftware.Description       = tu.Description;
             ToBeUpdatedSoftware.LastUpdateDate    = tu.LastUpdateDate;
             ToBeUpdatedSoftware.LastUpdateTime    = tu.LastUpdateTime;
             ToBeUpdatedSoftware.LastUpdateUser_ID = tu.LastUpdateUser_ID;
             ToBeUpdatedSoftware.Customer_ID       = tu.Customer_ID;
         }
         else
         {
             Tbl_OtherRequest ToBeInsertedSoftware = new Tbl_OtherRequest();
             ToBeInsertedSoftware.CustomerConnector = tu.CustomerConnector;
             ToBeInsertedSoftware.Description       = tu.Description;
             ToBeInsertedSoftware.RequestType_ID    = tu.RequestType_ID;
             ToBeInsertedSoftware.LastUpdateDate    = tu.LastUpdateDate;
             ToBeInsertedSoftware.LastUpdateTime    = tu.LastUpdateTime;
             ToBeInsertedSoftware.LastUpdateUser_ID = tu.LastUpdateUser_ID;
             ToBeInsertedSoftware.Customer_ID       = tu.Customer_ID;
             _context.Tbl_OtherRequest.Add(ToBeInsertedSoftware);
         }
         if (_context.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }