Ejemplo n.º 1
0
        public Result UpdateCustomer([FromBody]Customer customer, string customerName, String vault = null)
        {
            Result result = new Result();
            try
            {
                ConnectionInfo connInfo = setConnectionInfo(vault);

                SbeAccountManager.CManagerClass com = new SbeAccountManager.CManagerClass();
                SbeAccountManager.ICustomerCollection customerList;
                SbeAccountManager.CVaultConnectionClass v = new SbeAccountManager.CVaultConnectionClass();

                v.Address = connInfo.Address;
                v.DefaultRaidArea = connInfo.DefaultRaidArea;
                v.DefaultWorkArea = connInfo.DefaultWorkArea;
                v.Description = connInfo.Description;
                v.Domain = connInfo.Domain;
                v.Password = connInfo.ConnectionPassword;
                v.userName = connInfo.ConnectionUser;

                com.LogFileName = connInfo.LogFileName;
                com.AuditFileName = connInfo.AuditFileName;

                customerList = (SbeAccountManager.ICustomerCollection)com.getCustomerList(v);

                List<Customer> customers = new List<Customer>();

                //unfortunately we have to iterate through the list to find the match
                Boolean found = false;
                foreach (SbeAccountManager.ICustomer c in customerList)
                {

                    if (customerName == c.Name)
                    {
                        found = true;
                        if (!String.IsNullOrEmpty(customer.CustomerName)) c.Name = customer.CustomerName;
                        if (!String.IsNullOrEmpty(customer.CustomerAddress)) c.Address = customer.CustomerAddress;
                        if (!String.IsNullOrEmpty(customer.CustomerCity)) c.City = customer.CustomerCity;
                        if (!String.IsNullOrEmpty(customer.CustomerEmail)) c.Email = customer.CustomerEmail;
                        if (!String.IsNullOrEmpty(customer.CustomerCountry)) c.Country = customer.CustomerCountry;
                        if (!String.IsNullOrEmpty(customer.CustomerZipCode)) c.ZipCode = customer.CustomerZipCode;
                        if (!String.IsNullOrEmpty(customer.CustomerURL)) c.Url = customer.CustomerURL;
                        if (!String.IsNullOrEmpty(customer.CustomerState)) c.State = customer.CustomerState;
                        if (!String.IsNullOrEmpty(customer.CustomerContactName)) c.ContactPerson = customer.CustomerContactName;
                        c.update(v);

                        SbeAccountManager.ICollection locations;
                        locations = com.getLocationList(v, c.Id);

                        foreach (SbeAccountManager.ILocation l in locations)
                        {
                            //l.Email = customer.CustomerEmail;
                            //l.update(v, false);

                            SbeAccountManager.ICollection accounts = com.getAccountList(v, l.Id);

                            foreach (SbeAccountManager.IAccount a in accounts)
                            {

                                //a.Name = customer.ShortName;
                                //a.Description = customer.Description;
                                //a.update(v);
                            }

                        }

                        break;

                    }

                }
                if (!found)
                {
                    result.IsError = true;
                    result.ReturnCode = 2;
                    result.Message = "Customer not found";
                }
            }
            catch (Exception exception)
            {
                result.ReturnCode = 1;
                result.IsError = true;
                result.Message = exception.Message;

            }

            return SetErrorResultCode(result);
        }
Ejemplo n.º 2
0
        // DisableCustomer api/account/5
        public Result EnableCustomer(string customerName, String vault = null)
        {
            Result result = new Result();
            try
            {
                ConnectionInfo connInfo = setConnectionInfo(vault);

                SbeAccountManager.CManagerClass com = new SbeAccountManager.CManagerClass();
                SbeAccountManager.ICustomerCollection customerList;
                SbeAccountManager.CVaultConnectionClass v = new SbeAccountManager.CVaultConnectionClass();

                v.Address = connInfo.Address;
                v.DefaultRaidArea = connInfo.DefaultRaidArea;
                v.DefaultWorkArea = connInfo.DefaultWorkArea;
                v.Description = connInfo.Description;
                v.Domain = connInfo.Domain;
                v.Password = connInfo.ConnectionPassword;
                v.userName = connInfo.ConnectionUser;

                com.LogFileName = connInfo.LogFileName;
                com.AuditFileName = connInfo.AuditFileName;

                customerList = (SbeAccountManager.ICustomerCollection)com.getCustomerList(v);

                List<Customer> customers = new List<Customer>();

                //unfortunately we have to iterate through the list to find the match
                Boolean found = false;
                foreach (SbeAccountManager.ICustomer cust in customerList)
                {

                    if (customerName == cust.Name)
                    {
                        found = true;
                        SbeAccountManager.ICollection locations;
                        locations = com.getLocationList(v, cust.Id);

                        foreach (SbeAccountManager.ILocation location in locations)
                        {
                            SbeAccountManager.ICollection accounts = com.getAccountList(v, location.Id);

                            foreach (SbeAccountManager.IAccount account in accounts)
                            {
                                com.enableObject(v, SbeAccountManager.OBJECT_TYPE_ENUM.OTE_ACCOUNT, account.Id, true);
                            }

                        }

                        break;

                    }

                }

                if (!found)
                {
                    result.IsError = true;
                    result.ReturnCode = 2;
                    result.Message = "Customer not found";
                }

            }
            catch (Exception exception)
            {
                result.ReturnCode = 1;
                result.IsError = true;
                result.Message = exception.Message;

            }

            return SetErrorResultCode(result);
        }