示例#1
0
        public ActionResult CreateCustomer(NewCustomerModel model)
        {
            if (!ModelState.IsValid)
            {
                return View("New", model);
            }

            var foundCustomer = CustomerService.GetCustomer(model.Name);
            if (foundCustomer != null)
            {
                ModelState.AddModelError("Name", "A customer with this company name is already registered.");
                return View("New", model);
            }

            try
            {
                var customer = new Customer
                {
                    Name = model.Name,
                    BillingContact = model.BillingContact,
                    BillingContactEmail = model.BillingContactEmail,
                    TechnicalContact = model.TechnicalContact,
                    TechnicalContactEmail = model.TechnicalContactEmail,
                    IsHosted = model.IsHosted
                };

                CustomerService.CreateCustomer(customer);
            }
            catch (Exception ex)
            {
                QuietLog.LogHandledException(ex);
            }

            return SafeRedirect(Url.AdminCustomers());
        }
示例#2
0
        public async Task <NewCustomerModel> GetCustomerDetails(long customerId, System.Security.Principal.IPrincipal User)
        {
            var customer = await new Core.Domain.UserAccess(new SharedContext(), User).getAccessibleCustomers().Where(c => c.customer_auto == customerId).FirstOrDefaultAsync();

            if (customer == null)
            {
                return(null);
            }
            string logo = "";

            try {
                logo = Convert.ToBase64String(customer.logo);
            } catch
            {
                logo = null;
            }
            var dealergroupRecord = _context.DEALERGROUP_CUSTOMER_RELATION.Where(m => m.CustomerId == customerId && m.RecordStatus == (int)Core.Domain.RecordStatus.Available);

            var response = new NewCustomerModel()
            {
                Address            = customer.fullAddress,
                CustomerName       = customer.cust_name,
                DealershipId       = customer.DealershipId,
                DealerGroupId      = dealergroupRecord.Count() == 1 ? dealergroupRecord.FirstOrDefault().DealerGroupId : 0,
                Email              = customer.cust_email,
                Logo               = logo,
                PhoneNumber        = customer.cust_phone,
                ReportStyleId      = customer.SelectedReportId == null ? 0 : (int)customer.SelectedReportId,
                QuoteReportStyleId = customer.QuoteReportStyle == null ? 0 : (int)customer.QuoteReportStyle,
                HourlyLabourCost   = customer.DefaultHourlyRate,
            };

            return(response);
        }
示例#3
0
        public IActionResult OnPost([FromForm(Name = "ViewModel.NewCustomer")] NewCustomerModel newCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ViewModel.Update(newCustomer);
            return(RedirectToPage("List"));
        }
        public async Task <PartialViewResult> Create(NewCustomerModel newCustomerModel)
        {
            Customer             entity;
            CreatedCustomerModel createdCustomerModel;
            IAggregatePartner    operations;

            try
            {
                operations = await new SdkContext().GetPartnerOperationsAysnc();
                entity     = new Customer()
                {
                    BillingProfile = new CustomerBillingProfile()
                    {
                        CompanyName    = newCustomerModel.Name,
                        Culture        = "en-US",
                        DefaultAddress = new Address()
                        {
                            AddressLine1 = newCustomerModel.AddressLine1,
                            AddressLine2 = newCustomerModel.AddressLine2,
                            City         = newCustomerModel.City,
                            Country      = AppConfig.CountryCode,
                            FirstName    = newCustomerModel.FirstName,
                            LastName     = newCustomerModel.LastName,
                            PhoneNumber  = newCustomerModel.PhoneNumber,
                            PostalCode   = newCustomerModel.ZipCode,
                            State        = newCustomerModel.State
                        },
                        Email     = newCustomerModel.EmailAddress,
                        FirstName = newCustomerModel.FirstName,
                        Language  = "en",
                        LastName  = newCustomerModel.LastName
                    },
                    CompanyProfile = new CustomerCompanyProfile()
                    {
                        CompanyName = newCustomerModel.Name,
                        Domain      = $"{newCustomerModel.PrimaryDomain}.onmicrosoft.com"
                    }
                };

                entity = await operations.Customers.CreateAsync(entity);

                createdCustomerModel = new CreatedCustomerModel()
                {
                    Domain   = $"{newCustomerModel.PrimaryDomain}.onmicrosoft.com",
                    Password = entity.UserCredentials.Password,
                    Username = entity.UserCredentials.UserName
                };

                return(PartialView("CreatedSuccessfully", createdCustomerModel));
            }
            finally
            {
                entity = null;
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            var cust = new CustomersAccessor();
            var ord  = new OrdersAccessor();
            var prod = new ProductsAccessor();

            var db = cust.GetDatabase();

            NewCustomerModel newCustomer = new NewCustomerModel()
            {
                Email    = "*****@*****.**",
                Password = "******",
                Name     = "Larry The Janitor",
                Street   = "2720 36th Ave",
                City     = "San Francisco",
                Country  = "USA",
                NewOrder = new NewOrderModel()
                {
                    Items = new List <NewOrderModel.OrderItem>()
                    {
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 12
                        },
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 3
                        },
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 11
                        },
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 66
                        },
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 1
                        },
                        new NewOrderModel.OrderItem()
                        {
                            ProductId = 1, Units = 13
                        },
                    }
                }
            };

            cust.NewCustomer(newCustomer);
            prod.ChangePrice(new[] { 1, 2 }, new[] { 200m, 100m });


            var stats = cust.GetStats(DateTime.UtcNow.AddDays(-100));
        }
示例#6
0
        public void Update(NewCustomerModel newCustomer)
        {
            var newCustomerDetails = new NewCustomer()
            {
                CustomerNumber = newCustomer.CustomerNumber,
                FullName       = newCustomer.FullName,
                Address        = newCustomer.Address
            };

            facade.UpdateCustomerDetails(newCustomerDetails);
        }
示例#7
0
        public void Create(NewCustomerModel newCustomer)
        {
            //map
            var customer = new NewCustomer()
            {
                CustomerNumber = Guid.NewGuid().ToString().Split('-')[0],
                FullName       = $"{newCustomer.FirstName} {newCustomer.LastName}",
                Address        = $"{newCustomer.Address}"
            };

            //create
            facade.AddNewCustomer(customer);
        }
示例#8
0
        public async Task <IActionResult> Post([FromBody] NewCustomerModel newCustomerModel)
        {
            _cache.Set(newCustomerModel.TransactionId.ToString(), newCustomerModel, TimeSpan.FromDays(1));

            var message = new CloudEvent <NewCustomerModel>
            {
                TransactionId = newCustomerModel.TransactionId.ToString(),
                Data          = newCustomerModel
            };

            await _messageSender.SendAsync(message);

            return(CreateResponseOnPost(newCustomerModel));
        }
        public async Task <PartialViewResult> Create()
        {
            IAggregatePartner operations = await new SdkContext().GetPartnerOperationsAysnc();

            PartnerCenter.Models.CountryValidationRules.CountryValidationRules rules
                = await operations.CountryValidationRules.ByCountry(AppConfig.CountryCode).GetAsync();

            // TODO - Do not get the supported states list each time. This data should be cached so the forms will load more rapidly.
            NewCustomerModel newCustomerModel = new NewCustomerModel()
            {
                SupportedStates = rules.SupportedStatesList
            };

            return(PartialView(newCustomerModel));
        }
示例#10
0
        public void GetCustomer(string customerNumber)
        {
            var customer = facade.GetCustomerDetails(customerNumber);

            this.NewCustomer =
                new NewCustomerModel()
            {
                CustomerNumber = customer.CustomerNumber,
                FirstName      = customer.FullName.Split(',')[0].Split(' ')[0].Trim(),
                LastName       = customer.FullName.Split(',')[0].Split(' ')[1].Trim(),
                Street         = customer.Address.Split(',')[0].Trim(),
                City           = customer.Address.Split(',')[1].Trim(),
                State          = customer.Address.Split(',')[2].Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries)[0].Trim(),
                PostalCode     = customer.Address.Split(',')[2].Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries)[1].Trim(),
            };
        }
示例#11
0
        public ActionResult Index(string CompanyName, string Email, int?RoleTypeId, string Name, string operation, string ShowMessage, string MessageBody)
        {
            UserPermissionAction("vendor", RoleAction.view.ToString(), operation, ShowMessage, MessageBody);
            CheckPermission();
            var model  = new NewCustomerModel();
            var models = new List <CustomerModel>();

            model.UserTypeTitle = "All Product";
            var Vendors = _CustomerService.GetCustomers().Where(c => c.UserId != 1).AsEnumerable();

            if (!string.IsNullOrEmpty(CompanyName) && !string.IsNullOrEmpty(Email))
            {
                Vendors = Vendors.Where(x => x.Companies.CompanyName.Contains(CompanyName.Trim()) && x.EmailId.Contains(Email.Trim()));
            }
            if (!string.IsNullOrEmpty(CompanyName) && !string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Name))
            {
                Vendors = Vendors.Where(x => x.Companies.CompanyName.Contains(CompanyName.Trim()) && x.EmailId.Contains(Email.Trim()) && x.FirstName.Contains(Name.Trim()));
            }
            if (!string.IsNullOrEmpty(CompanyName) && !string.IsNullOrEmpty(Name))
            {
                Vendors = Vendors.Where(x => x.Companies.CompanyName.Contains(CompanyName.Trim()) && x.FirstName.Contains(Name.Trim()));
            }
            if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Email))
            {
                Vendors = Vendors.Where(x => x.FirstName.Contains(Name.Trim()) && x.EmailId.Contains(Email.Trim()));
            }
            if (!string.IsNullOrEmpty(CompanyName) && !string.IsNullOrEmpty(Email))
            {
                Vendors = Vendors.Where(x => x.Companies.CompanyName.Contains(CompanyName.Trim()) && x.EmailId.Contains(Email.Trim()));
            }
            if (!string.IsNullOrEmpty(CompanyName))
            {
                Vendors = Vendors.Where(x => x.Companies.CompanyName.Contains(CompanyName.Trim()));
            }
            if (!string.IsNullOrEmpty(Email))
            {
                Vendors = Vendors.Where(x => x.EmailId.Contains(Email.Trim()));
            }

            if (!string.IsNullOrEmpty(Name))
            {
                Vendors = Vendors.Where(x => x.FirstName.Contains(Name.Trim()));
            }
            if (!string.IsNullOrEmpty(RoleTypeId.ToString()))
            {
                Vendors = Vendors.Where(x => x.RoleType.Contains(RoleTypeId.ToString()));

                if (Convert.ToInt32(EnumValue.RoleType.Engineer_Procurement) == RoleTypeId)
                {
                    model.UserTypeTitle = EnumValue.RoleType.Engineer_Procurement.ToString();
                }
                else if (Convert.ToInt32(EnumValue.RoleType.manufacturer_Supplier) == RoleTypeId)
                {
                    model.UserTypeTitle = EnumValue.RoleType.manufacturer_Supplier.ToString();
                }
                else if (Convert.ToInt32(EnumValue.RoleType.Field_Consultant) == RoleTypeId)
                {
                    model.UserTypeTitle = EnumValue.RoleType.Field_Consultant.ToString();
                }
                else if (Convert.ToInt32(EnumValue.RoleType.Enter_As_Guest) == RoleTypeId)
                {
                    model.UserTypeTitle = EnumValue.RoleType.Enter_As_Guest.ToString();
                }
            }
            Mapper.CreateMap <Onlo.Entity.Customer, Onlo.Models.CustomerModel>();
            foreach (var Vendor in Vendors)
            {
                var _vendor = Mapper.Map <Onlo.Entity.Customer, Onlo.Models.CustomerModel>(Vendor);
                var Company = _CompanyService.GetCompany(Vendor.CompanyID);
                if (Company != null)
                {
                    _vendor.CompanyName         = Company.CompanyName;
                    _vendor.CompanyAddress      = Company.CompanyAddress;
                    _vendor.LogoPath            = Company.LogoPath;
                    _vendor.BusinessBrochureUrl = Company.BusinessBrochureUrl;
                }

                models.Add(_vendor);
            }
            if (models.ToList().Count == 0)
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = "No Record found !";
            }
            model.CustomerModelList = models;
            IEnumerable <EnumValue.RoleType> RoleTypes = Enum.GetValues(typeof(EnumValue.RoleType))
                                                         .Cast <EnumValue.RoleType>();

            model.RoleTypes = from action in RoleTypes
                              select new SelectListItem
            {
                Text  = action.ToString(),
                Value = ((int)action).ToString()
            };


            return(View(model));
        }
示例#12
0
        public Tuple <long, string> AddNewCustomer(NewCustomerModel customer, int _userId)
        {
            if (!checkCustomerNameIsUnique(customer.CustomerName))
            {
                return(Tuple.Create(Convert.ToInt64(-1), "A customer with this name already exists. "));
            }

            string[] LogoArr      = customer.Logo.Split(',');
            string   customerLogo = "";

            if (LogoArr.Length > 1)
            {
                customerLogo = LogoArr[1];
            }
            int?reportId = null;

            if (customer.ReportStyleId != 0)
            {
                reportId = customer.ReportStyleId;
            }
            CUSTOMER newCustomer = new CUSTOMER()
            {
                cust_name         = customer.CustomerName,
                custid            = customer.CustomerName,
                active            = true,
                billing_address   = false,
                Showlimits        = false,
                DealershipId      = customer.DealershipId,
                cust_phone        = customer.PhoneNumber,
                cust_email        = customer.Email,
                created_date      = DateTime.UtcNow,
                CreatedByUserId   = customer.CreatedByUserId,
                fullAddress       = customer.Address,
                labonly           = false,
                logo              = customerLogo != "" ? Convert.FromBase64String(customerLogo) : null,
                SelectedReportId  = reportId,
                QuoteReportStyle  = customer.QuoteReportStyleId,
                DefaultHourlyRate = customer.HourlyLabourCost,
            };

            _context.CUSTOMER.Add(newCustomer);

            try
            {
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(Tuple.Create(Convert.ToInt64(-1), e.Message));
            }

            /*
             * long[] userIds = _context.UserAccessMaps.Where(a => (a.DealershipId == customer.DealershipId && a.AccessLevelTypeId == (int)UserAccessTypes.DealershipAdministrator)
             || a.AccessLevelTypeId == (int)UserAccessTypes.GlobalAdministrator)
             ||                                         .Where(m => m.user_auto != null).Select(u => (long)u.user_auto).ToArray();
             ||
             ||foreach (long userId in userIds)
             ||{
             || USER_CRSF_CUST_EQUIP accessRecord = new USER_CRSF_CUST_EQUIP()
             || {
             ||     user_auto = userId,
             ||     customer_auto = newCustomer.customer_auto,
             ||     level_type = 1,
             ||     modified_user = "******"
             || };
             || _context.USER_CRSF_CUST_EQUIP.Add(accessRecord);
             ||}
             ||
             ||try
             ||{
             || _context.SaveChanges();
             ||}
             ||catch (Exception e)
             ||{
             || return Tuple.Create(Convert.ToInt64(-1), e.Message);
             ||}*/
            if (customer.DealerGroupId != 0)
            {
                var result = new BLL.Core.Domain.UserAccessDomain.DealerGroupAccess(new SharedContext(), _userId).AddCustomerToDealerGroup(customer.DealerGroupId, newCustomer.customer_auto.LongNullableToInt());
                if (result.OperationSucceed)
                {
                    return(Tuple.Create(newCustomer.customer_auto, "Successfully created new customer. "));
                }
                else
                {
                    return(Tuple.Create(newCustomer.customer_auto, "Operation completed with warning! This customer could not be registered for the selected dealer group!"));
                }
            }
            else if (customer.DealershipId != 0)
            {
                var result = new BLL.Core.Domain.UserAccessDomain.DealerAccess(new SharedContext(), _userId).AddCustomerToDealer(customer.DealershipId, newCustomer.customer_auto.LongNullableToInt());
                if (result.OperationSucceed)
                {
                    return(Tuple.Create(newCustomer.customer_auto, "Successfully created new customer. "));
                }
                else
                {
                    return(Tuple.Create(newCustomer.customer_auto, "Operation completed with warning! This customer could not be registered for the selected dealer !"));
                }
            }
            return(Tuple.Create(Convert.ToInt64(-1), "Please select dealer or dealer group! "));
        }
 public void NewCustomer(NewCustomerModel customer) => this.Execute(customer);