Example #1
0
        public void ActivateConfiguration(int id)
        {
            try
            {
                var repo = new RepositoryFactory().CreateRepository <ServerConfig>();

                ServerConfig config = null;

                //deactivate currently activated server
                config = repo.Get(x => x.IsActive).FirstOrDefault();
                if (config != null)
                {
                    config.IsActive = false;
                    repo.AddOrUpdate(config);
                }

                //activate server
                config          = repo.Get(x => x.ID == id).FirstOrDefault();
                config.IsActive = true;
                repo.AddOrUpdate(config);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 public void AddOrder([FromBody] SalesOrder so)
 {
     try
     {
         so.Status = "Pending";
         var repo = new RepositoryFactory().CreateOrderRepository();
         repo.AddOrUpdate(so);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
        public string AddOrUpdateUser(User user)
        {
            try
            {
                var repo = new RepositoryFactory().CreateUserRepository();
                repo.AddOrUpdate(user);

                return("Success");
            }
            catch (Exception ex)
            {
                return("Unable to save user. Please contact administrator.");
            }
        }
        public string SaveAPI(ClientAPI api)
        {
            try
            {
                var repo = new RepositoryFactory().CreateClientAPIRepository();
                repo.AddOrUpdate(api);

                return("Success");
            }
            catch (Exception ex)
            {
                return("Unable to save new API. Please contact administrator.");
            }
        }
Example #5
0
        public void AddConfiguration(ServerConfig config, bool isActive)
        {
            try
            {
                var repo = new RepositoryFactory().CreateRepository <ServerConfig>();
                if (isActive)
                {
                    config.IsActive = true;
                    var deactivateConfig = repo.Get(x => x.IsActive).FirstOrDefault();
                    if (deactivateConfig != null)
                    {
                        deactivateConfig.IsActive = false;
                        repo.AddOrUpdate(deactivateConfig);
                    }
                }

                repo.AddOrUpdate(config);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
        public ErrorLog AddErrLog(ErrorLog err)
        {
            try
            {
                var      repo = new RepositoryFactory().CreateRepository <ErrorLog>();
                ErrorLog _err = new ErrorLog();
                _err.Message        = err.Message;
                _err.ErrorCode      = err.ErrorCode;
                _err.StackTrace     = err.StackTrace;
                _err.CreatedOn      = DateTime.Now;
                _err.LastModifiedOn = DateTime.Now;
                repo.AddOrUpdate(err);

                return(repo.Get(x => x.ID == _err.ID).FirstOrDefault());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }