Beispiel #1
0
        public ActionResult SubmitInstallation(InstallationListModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;

            try
            {
                Tbl_Installation tu = new Tbl_Installation();
                tu.AdministratorPassword = model.AdministratorPassword;
                tu.ClientsNumber         = model.ClientsNumber;
                tu.CPU = model.CPU;
                tu.CustomerConnector     = model.CustomerConnector;
                tu.Customer_ID           = model.Customer_ID;
                tu.DeliveryDate_Customer = model.DeliveryDate_Customer;
                tu.DeliveryDate_SOHA     = model.DeliveryDate_SOHA;
                tu.Description           = model.Description;
                tu.InstallationLocation  = model.InstallationLocation_ID;
                tu.InstallationProgram   = model.InstallationProgram_ID;
                tu.Installation_ID       = model.Installation_ID;
                tu.IPServer = model.IPServer;
                tu.PurchasedDevicesNumber = model.PurchasedDevicesNumber;
                tu.RAM = model.RAM;
                tu.SendSystemRequirements = model.SendSystemRequirements_ID;
                tu.SystemType             = model.SystemType_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.AddNewInstallation(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new InstallationModel
                        {
                            Message      = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return(Json(gridModel));
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new InstallationModel
                        {
                            Message      = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return(Json(gridModel));
                }
            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new InstallationModel
                    {
                        Message      = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return(Json(gridModel));
            }
            //return "";
        }
Beispiel #2
0
 public bool AddNewInstallation(Tbl_Installation tu)
 {
     try
     {
         if (tu.Installation_ID != 0)
         {
             // user already exists
             Tbl_Installation ToBeUpdatedInstallation = _context.Tbl_Installation.First(x => x.Installation_ID == tu.Installation_ID);
             ToBeUpdatedInstallation.AdministratorPassword = tu.AdministratorPassword;
             ToBeUpdatedInstallation.ClientsNumber         = tu.ClientsNumber;
             ToBeUpdatedInstallation.CPU = tu.CPU;
             ToBeUpdatedInstallation.CustomerConnector     = tu.CustomerConnector;
             ToBeUpdatedInstallation.Customer_ID           = tu.Customer_ID;
             ToBeUpdatedInstallation.DeliveryDate_Customer = tu.DeliveryDate_Customer;
             ToBeUpdatedInstallation.DeliveryDate_SOHA     = tu.DeliveryDate_SOHA;
             ToBeUpdatedInstallation.Description           = tu.Description;
             ToBeUpdatedInstallation.InstallationLocation  = tu.InstallationLocation;
             ToBeUpdatedInstallation.InstallationProgram   = tu.InstallationProgram;
             ToBeUpdatedInstallation.Installation_ID       = tu.Installation_ID;
             ToBeUpdatedInstallation.IPServer = tu.IPServer;
             ToBeUpdatedInstallation.PurchasedDevicesNumber = tu.PurchasedDevicesNumber;
             ToBeUpdatedInstallation.RAM = tu.RAM;
             ToBeUpdatedInstallation.SendSystemRequirements = tu.SendSystemRequirements;
             ToBeUpdatedInstallation.SystemType             = tu.SystemType;
             ToBeUpdatedInstallation.LastUpdateDate         = tu.LastUpdateDate;
             ToBeUpdatedInstallation.LastUpdateTime         = tu.LastUpdateTime;
             ToBeUpdatedInstallation.LastUpdateUser_ID      = tu.LastUpdateUser_ID;
         }
         else
         {
             Tbl_Installation ToBeInsertedInstallation = new Tbl_Installation();
             ToBeInsertedInstallation.AdministratorPassword = tu.AdministratorPassword;
             ToBeInsertedInstallation.ClientsNumber         = tu.ClientsNumber;
             ToBeInsertedInstallation.CPU = tu.CPU;
             ToBeInsertedInstallation.CustomerConnector     = tu.CustomerConnector;
             ToBeInsertedInstallation.Customer_ID           = tu.Customer_ID;
             ToBeInsertedInstallation.DeliveryDate_Customer = tu.DeliveryDate_Customer;
             ToBeInsertedInstallation.DeliveryDate_SOHA     = tu.DeliveryDate_SOHA;
             ToBeInsertedInstallation.Description           = tu.Description;
             ToBeInsertedInstallation.InstallationLocation  = tu.InstallationLocation;
             ToBeInsertedInstallation.InstallationProgram   = tu.InstallationProgram;
             ToBeInsertedInstallation.Installation_ID       = tu.Installation_ID;
             ToBeInsertedInstallation.IPServer = tu.IPServer;
             ToBeInsertedInstallation.PurchasedDevicesNumber = tu.PurchasedDevicesNumber;
             ToBeInsertedInstallation.RAM = tu.RAM;
             ToBeInsertedInstallation.SendSystemRequirements = tu.SendSystemRequirements;
             ToBeInsertedInstallation.SystemType             = tu.SystemType;
             ToBeInsertedInstallation.LastUpdateDate         = tu.LastUpdateDate;
             ToBeInsertedInstallation.LastUpdateTime         = tu.LastUpdateTime;
             ToBeInsertedInstallation.LastUpdateUser_ID      = tu.LastUpdateUser_ID;
             _context.Tbl_Installation.Add(ToBeInsertedInstallation);
         }
         if (_context.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }