public void Can_CreateCoreCustomer()
        {
            //Arrange
            var customerModel = new Models.Customer
            {
                CustomerReference = "ABCD1234",
                RoleType = "Master Tenant",
                Gender = "Male",
                Status = "Active",
                Title = "Mr",
                GivenName = "Kristian",
                AdditionalName = "John",
                FamilyName = "Wilson",
                KnownAs = "Kris"
            };

            //Act
            var result = CustomerFactory.CreateCoreCustomer(customerModel);

            //Assert
            result.Should().NotBeNull();
            result.CustomerReference.Should().Be("ABCD1234");
            result.RoleType.Should().Be(RoleType.MasterTenant);
            result.Gender.Should().Be(GenderType.Male);
            result.Names.Any().Should().BeTrue();
            result.Names.First().Title.Should().Be(Title.Mr);
            result.Names.First().GivenName.Should().Be("Kristian");
            result.Names.First().AdditionalName.Should().Be("John");
            result.Names.First().FamilyName.Should().Be("Wilson");
            result.Names.First().KnownAs.Should().Be("Kris");
        }
Exemplo n.º 2
0
        public ActionResult Add()
        {
            Models.Customer m = new Models.Customer();
            m.CreateTime = DateTime.Now;
            m.Age = 30;

            return View(m);
        }
Exemplo n.º 3
0
        public Customer CreateUser(string name)
        {
            using (var db = new BaseContext())
            {
                var newCustomer = new Models.Customer() { Name = name };
                db.Customers.Add(newCustomer);
                db.SaveChanges();

                return newCustomer;
            }
        }
        public IEnumerable<Models.Customer> GetAllCustomers()
        {
            List<Models.Customer> customerList;

            ObjectCache cache = MemoryCache.Default;
            customerList = (List<Models.Customer>)cache.Get("CustomerList");

            if (customerList == null)
            {
                CacheItemPolicy policy = new CacheItemPolicy();

                //Connection String
                string connectionString = WebConfigurationManager.ConnectionStrings["CustomerNodeConnection"].ConnectionString;

                using (var connection = new SqlConnection(connectionString))
                {
                    using (var command = connection.CreateCommand())
                    {
                        connection.Open();
                        command.CommandType = System.Data.CommandType.StoredProcedure;
                        command.CommandText = "dbo.upGetAllCustomers";

                        using (var reader = command.ExecuteReader())
                        {
                            if (reader != null && reader.HasRows)
                            {
                                //Initialize a Customer
                                Models.Customer customer = null;
                                //Create a List to hold multiple Customers
                                customerList = new List<Models.Customer>();

                                while (reader.Read())
                                {
                                    //Create and hydrate a new Object
                                    customer = new Models.Customer();
                                    customer.CustomerId = Convert.ToInt32(reader["CustomerId"]);
                                    customer.FirstName = Convert.ToString(reader["FirstName"]).Trim();
                                    customer.LastName = Convert.ToString(reader["LastName"]).Trim();

                                    //Add to List
                                    customerList.Add(customer);
                                }

                                policy.SlidingExpiration = TimeSpan.FromSeconds(30);
                                cache.Add("CustomerList", customerList, policy);
                            }
                        }
                    }
                }
            }
            //Return List
            return customerList;
        }
        public async Task <ActionResult> CreateCustomer(CreateCustomerViewModel model)
        {
            var userId   = User.Identity.GetUserId();
            var customer = new Models.Customer
            {
                Name    = model.Name,
                Address = model.Address,
            };

            using (var context = new ProductContolEntities())
            {
                context.Customers.Add(customer);

                await context.SaveChangesAsync();
            }
            return(RedirectToAction("Index", "Home", new { area = "" }));
        }
Exemplo n.º 6
0
        public async Task<IActionResult> OnPostAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            Customer = await _context.Customers.FindAsync(id);

            if (Customer != null)
            {
                _context.Customers.Remove(Customer);
                await _context.SaveChangesAsync();
            }

            return RedirectToPage("./Index");
        }
Exemplo n.º 7
0
        // Create / Update
        public void Save(Customer c)
        {
            if (c.Id < 1)
            {
                GeocodeAddress(c);
                _dao.Create(c);
            }
            else
            {
                if (IsNewAddress(c))
                {
                    GeocodeAddress(c);
                }

                _dao.Update(c);
            }
        }
Exemplo n.º 8
0
        public System.Web.Mvc.ActionResult GetCustomerById(int id)
        {
            var inputId = id;

            SalesService.Models.Customer custmerById;
            using (var salesDBEntities = new SalesDBEntities())
            {
                var customerFromDatabase = salesDBEntities.Customers.Where(item => item.CustomerID == id).ToList().First();
                custmerById = new Models.Customer()
                {
                    FirstName = customerFromDatabase.FirstName, CustomerID = customerFromDatabase.CustomerID, LastName = customerFromDatabase.LastName, MiddleInitial = customerFromDatabase.MiddleInitial
                };
            }
            var result = new System.Web.Mvc.JsonResult();

            result.Data = custmerById;
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the customers using SDK.
        /// </summary>
        public List <Models.Customer> GetCspCustomers(string customerId = null)
        {
            IAggregatePartner partner = GetPartnerCenterTokenUsingAppCredentials();
            // get customers list
            var allCustomers = partner.Customers.Get();
            //extract relevant data and put in a list
            var customerList = new List <Models.Customer>();

            //browse answer
            foreach (var thisCustomer in allCustomers.Items)
            {
                var newCustomer = new Models.Customer();
                newCustomer.CustomerName = thisCustomer.CompanyProfile.CompanyName;
                newCustomer.CustomerId   = thisCustomer.Id;
                customerList.Add(newCustomer);
            }
            return(customerList);
        }
Exemplo n.º 10
0
        public void SaveCustomer()
        {
            CustomerBL busEmp = new CustomerBL();

            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer emp = new Models.Customer();

                emp.GenderID = Convert.ToInt16(ddlGender.SelectedValue);
                emp.ID_No    = txtIDNumber.Text;
                emp.Name     = txtName.Text;
                emp.Surname  = txtSurname.Text;
                emp.Cell_No  = txtCellPhoneNO.Text;
                emp.Email    = txtEmail.Text;

                busEmp.CreateCustomer(emp);
            }
        }
Exemplo n.º 11
0
 public ActionResult Put(int id, [FromBody] Models.Customer customer)
 {
     try
     {
         var current = customerService.Get(customer.Id);
         current.Name = customer.Name;
         customerService.Update(current);
         return(Ok());
     }
     catch (InvalidOperationException ex)
     {
         return(NotFound());
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
Exemplo n.º 12
0
        // GET: Customer
        public ActionResult Index()
        {
            //ViewBag.ID = Convert.ToInt32(TempData["CustomerId"]);
            //TempData.Keep();
            var customers = db.GetCustomer();

            foreach (var customer in customers)
            {
                c            = new Models.Customer();
                c.Name       = customer.GetName(customer.FirstName, customer.LastName);
                c.CustomerId = customer.CustomerId;
                c.Username   = customer.Username;
                c.Password   = customer.Password;
                customerList.Add(c);
            }

            return(View(customerList));
        }
Exemplo n.º 13
0
        public ActionResult StartOrder()
        {
            Models.Customer customer = GetLoggedInCustomer();
            Models.Order    newOrder = new Models.Order();
            newOrder.CustomerId = customer.CustomerId;
            newOrder.TruckId    = customer.OrderTruckId;
            newOrder.FillTime   = DateTime.Now;
            newOrder.StartTime  = DateTime.Now;
            newOrder.Status     = 1;
            db.Orders.Add(newOrder);
            db.SaveChanges();
            customer.CurrentOrderId = newOrder.OrderId;
            db.SaveChanges();

            Menu truckMenu = GetTruckMenu(customer.OrderTruckId);

            return(View(db.MenuItems.Where(m => m.MenuId == truckMenu.MenuId && m.Category == "Drink").ToList()));
        }
Exemplo n.º 14
0
        public ActionResult Add(Models.Customer model)
        {
            model.CreateTime = DateTime.Now;

            //model.Phone = new List<Models.Phone>();
            //var phoneModel = new Models.Phone();
            //phoneModel.Number = Request.Form["PhoneNumber"] != null ? Request.Form["PhoneNumber"] : "";
            //phoneModel.CreateTime = DateTime.Now;
            //phoneModel.PhoneType = "默认号码";
            //phoneModel.Remark = "正常";
            //model.Phone.Add(phoneModel);

            db.Customers.Add(model);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 15
0
        public async Task ShouldIgnoreIdAndAddToTheCollection()
        {
            // Arrange
            var sut         = SetUpSystemUnderTest();
            var newCustomer = new Models.Customer {
                Id = Ids.INVALID_ID, Name = "Ellen"
            };

            // Act
            await sut.Create(TableNames.CUSTOMERS, newCustomer);

            var actual = await sut.ReadOne <Models.Customer>(TableNames.CUSTOMERS, $"[?(@.id=={Ids.ADDED_ID})]");

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.EqualTo(Ids.ADDED_ID));
            Assert.That(actual.Name, Is.EqualTo("Ellen"));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Customer = await _context.Customer
                       .Include(c => c.DeskQuotes)
                       .FirstOrDefaultAsync(c => c.CustomerID == id);

            if (Customer == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Exemplo n.º 17
0
        private float AddSurveyRatings(string userName)
        {
            float sum = 0;
            int count = 4;
            var random = new Random();

            for (int i = 0; i < count; i++)
            {
                var score = random.Next(80, 100);
                var customer = new Models.Customer(Guid.NewGuid(), userName, score);

                var insertOperation = TableOperation.Insert(customer);
                surveyRatingsTable.Execute(insertOperation);

                sum += score;
            }
            return sum / count;
        }
        public async Task <IActionResult> Edit(int id, Models.Customer customer)
        {
            try
            {
                //var custromerwithLatLng = await _geocoding.GetGeoCoding(customer);

                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                customer.IdentityUserId = userId;
                _context.Customers.Update(customer);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                Console.WriteLine("Error");
                return(View());
            }
        }
Exemplo n.º 19
0
        public async Task ShouldBeAbleToRetrieveNewCustomer()
        {
            // Arrange
            var sut         = SetUpSystemUnderTest();
            var newCustomer = new Models.Customer {
                Id = CustomerIds.NEW_ID, Name = "Ellen"
            };

            // Act
            await sut.AddCustomer(newCustomer);

            var actual = await sut.GetCustomerById(CustomerIds.ADDED_ID);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.EqualTo(CustomerIds.ADDED_ID));
            Assert.That(actual.Name, Is.EqualTo("Ellen"));
        }
Exemplo n.º 20
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         Models.Customer customer = new Models.Customer();
         customer.name    = collection["name"];
         customer.number  = collection["number"];
         customer.address = collection["address"];
         db.Customers.Add(customer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public async Task <IActionResult> Post([FromBody] Models.Customer customer)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var createdCustomer = await _customerService.Add(customer);

                return(Created("", createdCustomer));
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 22
0
        public void ShouldReturnTheSameCustomer()
        {
            var          customerId     = It.IsAny <string>();
            const string validEmail     = "*****@*****.**";
            const string validFirstName = "John";
            const string validSurname   = "Surname";
            const string validPassword  = "******";
            var          validCustomer  = new Models.Customer(validEmail, validFirstName, validSurname, validPassword);

            _mockCustomerService.Setup(s => s.GetById(customerId)).ReturnsAsync(validCustomer);
            var sut = new Controllers.CustomerController(_mockCustomerService.Object);

            var result = sut.Get(customerId).Result;

            var customer = (Models.Customer)((OkObjectResult)result).Value;

            Assert.Equal(validEmail, customer.Email);
        }
Exemplo n.º 23
0
        public IActionResult Register(Models.Customer a)
        {
            a.Password = (a.Password).Trim();
            a.Email    = (a.Email).Trim();
            int d = ECOMMERCE_MVC.Models.Customer.InsertCustomer(a, _connection);

            Debug.Write("Integer Message Is" + d);
            if (d == 1)
            {
                Models.Customer customer = Models.Customer.getCustomerDetailsByEmail(a.Email, _connection);
                HttpContext.Session.SetString("CustomerSession", JsonConvert.SerializeObject(customer));
                return(RedirectToAction("Index", "Item1", new { id = 47 }));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 24
0
        public async Task ShouldUpdateSuccessfullyInCollection()
        {
            // Arrange
            var sut = SetUpSystemUnderTest();
            var customerToUpdate = new Models.Customer {
                Id = Ids.UPDATE_ID, Name = "Bob"
            };

            // Act
            await sut.Update(TableNames.CUSTOMERS, customerToUpdate);

            var actual = await sut.ReadOne <Models.Customer>(TableNames.CUSTOMERS, $"[?(@.id=={Ids.UPDATE_ID})]");

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.EqualTo(Ids.UPDATE_ID));
            Assert.That(actual.Name, Is.EqualTo("Ellen"));
        }
Exemplo n.º 25
0
        public bool InsertCustomer(Models.Customer obj)

        {
            CustomerEntity objcust = new CustomerEntity()
            {
                CustomerId   = obj.CustomerId,
                CustomerName = obj.CustomerName,
                Address      = obj.Address,
                Email        = obj.Email
            };
            CUSTOMERDATAEntities db = new CUSTOMERDATAEntities();

            db.CustomerEntities.Add(objcust);

            //    db.AddToCustomerEntities(objcust);
            db.SaveChanges();
            return(true);
        }
Exemplo n.º 26
0
        private float AddSurveyRatings(string userName)
        {
            float sum    = 0;
            int   count  = 4;
            var   random = new Random();

            for (int i = 0; i < count; i++)
            {
                var score    = random.Next(80, 100);
                var customer = new Models.Customer(Guid.NewGuid(), userName, score);

                var insertOperation = TableOperation.Insert(customer);
                surveyRatingsTable.Execute(insertOperation);

                sum += score;
            }
            return(sum / count);
        }
Exemplo n.º 27
0
        public async Task ShouldBeAbleToRetrieveUpdatedCustomer()
        {
            // Arrange
            var sut = SetUpSystemUnderTest();
            var customerToUpdate = new Models.Customer {
                Id = CustomerIds.UPDATE_ID, Name = "Bob"
            };

            // Act
            await sut.UpdateCustomer(customerToUpdate);

            var actual = await sut.GetCustomerById(CustomerIds.UPDATE_ID);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.EqualTo(CustomerIds.UPDATE_ID));
            Assert.That(actual.Name, Is.EqualTo("Bob"));
        }
Exemplo n.º 28
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEmail.Text == "")
                {
                    txtEmail.Text = DefaultString;
                }
                if (txtAddress.Text == "")
                {
                    txtAddress.Text = DefaultString;
                }
                if (txtPhone.Text == "")
                {
                    txtPhone.Text = DefaultString;
                }
                if (txtNote.Text == "")
                {
                    txtNote.Text = DefaultString;
                }

                if (_customer == null)
                {
                    var customer = FormData;
                    _appContext.Customers.Add(customer);
                }
                else
                {
                    _customer.Name    = FormData.Name;
                    _customer.Sex     = FormData.Sex;
                    _customer.Phone   = FormData.Phone;
                    _customer.Email   = FormData.Email;
                    _customer.Note    = FormData.Note;
                    _customer.Address = FormData.Address;
                }
                _appContext.SaveChanges();
                _customer = null;
                MessageBox.Show("Successfuly", @"Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception + " ", @"Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Make a Person Full of Data
        /// </summary>
        /// <returns></returns>
        public static Models.Customer PersonMake()
        {
            var person = new Models.Customer()
            {
                _id      = Guid.NewGuid().ToString(),
                Birthday = Faker.DateOfBirth.Next(),
                EMail    = Faker.Internet.Email(),
                NameLast = Faker.Name.Last()
            };

            person.NameFirst = Faker.Name.First();

            person.Company = person.EMail.Substring(person.EMail.IndexOf('@') + 1);

            person.EMail = string.Format("{0}.{1}@{2}", person.NameFirst, person.NameLast, person.Company);

            for (int p = 0; p < Dice.Next(2, 6); p++)
            {
                person.Preference.Add(string.Format("{0}-{1}", Faker.Lorem.GetFirstWord(), p), Faker.Lorem.Sentence());
            }

            person.Addresses.Add(new Models.Address()
            {
                Address1 = string.Format("{0} {1} {2}", Dice.Next(101, 8888), Faker.Address.StreetName(), Faker.Address.StreetSuffix()),
                City     = Faker.Address.City(),
                State    = Faker.Address.UsStateAbbr(),
                Zip      = $"{Faker.Address.StreetName()} {Faker.Address.StreetSuffix()}",
                Kind     = Models.AddressKind.Mailing
            });

            if (Dice.Next(1, 10) > 7)
            {
                person.Addresses.Add(new Models.Address()
                {
                    Address1 = string.Format("{0} {1} {2}", Dice.Next(101, 8888), Faker.Address.StreetName(), Faker.Address.StreetSuffix()),
                    City     = Faker.Address.City(),
                    State    = Faker.Address.UsStateAbbr(),
                    Zip      = $"{Faker.Address.StreetName()} {Faker.Address.StreetSuffix()}",
                    Kind     = Models.AddressKind.Billing
                });
            }

            return(person);
        }
Exemplo n.º 30
0
        public async Task <Models.Customer> SaveCustomerAsync(Models.Customer item)
        {
            try
            {
                if (item.Id == null)
                {
                    if ((await this.customerTable.ToEnumerableAsync()).Any())
                    {
                        int lastCustomerNumber = (await this.customerTable.Select(c => int.Parse(c.CustomerNumber.TrimStart('C'))).ToListAsync()).Max();
                        item.CustomerNumber = $"C{lastCustomerNumber + 1}";
                    }
                    else
                    {
                        item.CustomerNumber = "C000001";
                    }
                    await customerTable.InsertAsync(item);
                }
                else
                {
                    await customerTable.UpdateAsync(item);
                }

                if (item.Addresses != null && item.Addresses.Count > 0)
                {
                    foreach (var addr in item.Addresses)
                    {
                        if (string.IsNullOrEmpty(addr.Id))
                        {
                            addr.Id = Guid.NewGuid().ToString("N");
                        }
                        addr.CustomerID = item.Id;
                    }
                    await customerTable.UpdateAsync(item);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Save error: {0}", new[] { e.Message });
                return(null);
            }

            this.messenger.Publish <CustomerUpdatedMessage>(new CustomerUpdatedMessage(this, item));
            return(item);
        }
Exemplo n.º 31
0
        public ActionResult SetUpStripe(CardInfo cardInfo)  // Create customer then create charge in next view
        {
            Models.Customer currentCustomer = GetLoggedInCustomer();
            Models.Order    currentOrder    = db.Orders.FirstOrDefault(o => o.OrderId == currentCustomer.CurrentOrderId);
            CardInfo        newCard         = new CardInfo();

            newCard.CardName   = cardInfo.CardName;
            newCard.Email      = cardInfo.Email;
            newCard.CustomerId = currentCustomer.CustomerId;
            db.Cards.Add(newCard);

            StripeConfiguration.ApiKey = (APIKeys.StripeApiKey);

            var options = new CustomerCreateOptions
            {
                Description = ("Customer for " + cardInfo.Email),
                Email       = cardInfo.Email,
                Source      = cardInfo.StripeToken
            };
            var service = new CustomerService();

            Stripe.Customer customer = service.Create(options);
            currentCustomer.CustomerStripeId = customer.Id;
            currentCustomer.IsStripeSetUp    = true;
            db.SaveChanges();

            var createOptions = new ChargeCreateOptions
            {
                Amount      = Convert.ToInt64(currentOrder.OrderPrice * 100),
                Currency    = "usd",
                Customer    = currentCustomer.CustomerStripeId, // Have to pass in customer ID since token can't be called twice
                Description = "Order for " + currentCustomer.FirstName + " " + currentCustomer.lastName,
            };
            var    createService = new ChargeService();
            Charge charge        = createService.Create(createOptions);

            var model = new Cart(); //Cart is like the charge view model from video

            model.ChargeId = charge.Id;

            // Perhaps payment will happen with this setup for the first time

            return(RedirectToAction("UniqueIdScreen")); // This redirect may have to change
        }
Exemplo n.º 32
0
 public static DTOs.Customer CreateFrom(
     Models.Customer customer,
     IEnumerable <Models.Category> categoryModels,
     IEnumerable <Models.Country> countryModels,
     IEnumerable <Models.Gender> genderModels)
 {
     return(new DTOs.Customer()
     {
         Id = customer.Id,
         Name = customer.Name,
         Gender = Factories.Gender.CreateFrom(genderModels, customer.GenderId),
         HouseNumber = customer.HouseNumber,
         AddressLine1 = customer.AddressLine1,
         State = customer.State,
         Country = Factories.Country.CreateFrom(countryModels, customer.CountryId),
         Category = Factories.Category.CreateFrom(categoryModels, customer.CategoryId),
         DateOfBirth = customer.DateOfBirth
     });
 }
Exemplo n.º 33
0
        public void CreateCustomer(Models.Customer model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer cus = new Models.Customer();

                cus.Cell_No        = model.Cell_No;
                cus.DateCreated    = model.DateCreated;
                cus.Email          = model.Email;
                cus.GenderID       = model.GenderID;
                cus.ID_No          = model.ID_No;
                cus.Loyalty_Points = model.Loyalty_Points;
                cus.Name           = model.Name;
                cus.Surname        = model.Surname;

                db.Customers.Add(cus);
                db.SaveChanges();
            }
        }
Exemplo n.º 34
0
        public async Task <IHttpActionResult> GetCustomer(string key)
        {
            Customer customer = await db.Customers.FirstOrDefaultAsync(c => c.Email == key || c.Mobile == key);

            if (customer == null)
            {
                return(Ok(new { custId = string.Empty }));
            }
            var cust = new Models.Customer
            {
                Email     = customer.Email,
                FirstName = customer.FirstName,
                Id        = customer.Id,
                LastName  = customer.LastName,
                Mobile    = customer.Mobile
            };

            return(Ok(cust));
        }
Exemplo n.º 35
0
        // GET: Order
        public ActionResult Index(Models.Customer arg)
        {
            ///取得聯絡人職稱
            Models.CodeService  codser = new Models.CodeService();
            Models.OrderService ser    = new Models.OrderService();

            ViewBag.CustContactTitle = codser.GetCustContactTitle();
            if (arg.indexboo)
            {
                ///條件客戶資料
                ViewBag.custdata = ser.GetCustInforby(arg);
            }
            else
            {
                ///客戶資料
                ViewBag.custdata = ser.GetCustInfor();
            }
            return(View());
        }
Exemplo n.º 36
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Customer = await _context.Customers
                       .Include(c => c.Membership)
                       .Include(c => c.Schedule).FirstOrDefaultAsync(m => m.Id == id);

            if (Customer == null)
            {
                return(NotFound());
            }
            ViewData["MembershipId"] = new SelectList(_context.Membership, "Id", "Id");
            ViewData["ScheduleId"]   = new SelectList(_context.Schedules, "Id", "Id");
            return(Page());
        }
        public HttpResponseMessage VaultTransaction(string guid)
        {
            HttpContent hc = Request.Content;
            Task<NameValueCollection> ReadTask = hc.ReadAsFormDataAsync();
            NameValueCollection formData = ReadTask.Result;
            string amount = formData.Get("amount");

            SEVD.Configuration config = new SEVD.Configuration(Credentials.MID, Credentials.MKEY, Credentials.APPID);
            Client sevdClient = new Client(config);

            Models.TransactionBase tb = new Models.TransactionBase(Models.TransactionBase.RequestType.Sale, false, amount);
            Models.Customer cust = new Models.Customer();

            string response = sevdClient.Transaction.DoVaultTransaction(tb, guid, cust);
            Models.TransactionResult tr = new Models.TransactionResult(response);
            SEVD.API.Configuration.DataAccess.WriteToDataBase(tr);

            HttpResponseMessage resp = Request.CreateResponse(HttpStatusCode.Redirect);
            resp.Headers.Location = new Uri(Settings.ReturnPage);
            return resp;
        }
Exemplo n.º 38
0
        static void Main(string[] args)
        {
            var cm1 = new Models.Customer("Pesho", "Atanosov", "Peshev", 8508156699, "Street 1", "+359895445566", "*****@*****.**", CustomerType.OneTime);

            var cm2 = new Models.Customer("Pesho", "Atanosov", "Peshev", 8508156699, "Iztok", "+359895445566", "*****@*****.**", CustomerType.Diamond);

            // Check if equal
            Console.WriteLine(cm1 == cm2);

            // Clone Cutomer
            var cm3 = (Models.Customer)cm2.Clone();

            cm3.AddPayment(
                new Payment("Kola", 5444),
                new Payment("Apartment", 99999));

            Console.WriteLine(cm3);
            Console.WriteLine(cm2);

            // Compare Cutomers
            Console.WriteLine(cm2.CompareTo(cm1));
        }
Exemplo n.º 39
0
        public ActionResult CreateCustomer(FormCollection inList)
        {
            try
            {
                using (var db = new Models.CustomerContext())
                {
                    var newCustomer = new Models.Customer();
                    newCustomer.FirstName = inList["FirstName"];
                    newCustomer.LastName = inList["LastName"];
                    newCustomer.Address = inList["Address"];
                    // kan ikke bruke dette array i LINQ nedenfor
                    string inZip = inList["ZipCode"];

                    var foundPostalArea = db.PostalArea
                   .FirstOrDefault(p => p.ZipCode == inZip);
                    if (foundPostalArea == null) // fant ikke poststed, må legge inn et nytt
                    {
                        var newPostalArea = new Models.PostalArea();
                        newPostalArea.ZipCode = inList["ZipCode"];
                        newPostalArea.PostalArea_ = inList["PostalArea"];
                        db.PostalArea.Add(newPostalArea);
                        // det nye poststedet legges i den nye brukeren
                        newCustomer.PostalArea = newPostalArea;
                    }
                    else
                    { // fant poststedet, legger det inn i den nye brukeren
                        newCustomer.PostalArea = foundPostalArea;
                    }
                    db.Customer.Add(newCustomer);
                    db.SaveChanges();
                    return RedirectToAction("GetAllCustomers");
                }
            }
            catch (Exception e)
            {
                return View();
            }
        }
Exemplo n.º 40
0
        public List<Models.Customer> GetCustomerList()
        {
            List<Models.Customer> list = new List<Models.Customer>();

            String connString = @"Data Source=klippan.privatedns.org;Initial Catalog=CreateCookies;Persist Security Info=True;User ID=grupp15;Password=Grupp15";
            SqlConnection sqlConn = new SqlConnection(connString);
            sqlConn.Open();

            String query = "SELECT * FROM Customer";
            SqlCommand cmd = new SqlCommand(query, sqlConn);
            SqlDataReader reader = cmd.ExecuteReader();

            try
            {
                while (reader.Read())
                {
                    var result = new Models.Customer();
                    result.CNumber = reader.GetString(0);
                    result.CName = reader.GetString(1);
                    result.CAddress = reader.GetString(2);
                    result.CPostalAddress = reader.GetString(3);
                    result.CCountry = reader.GetString(4);
                    result.CEmail = reader.GetString(5);

                    list.Add(result);

                }
            }
            catch (Exception)
            {

                throw;
            }

            return list;

        }
Exemplo n.º 41
0
        private void GeocodeAddress(Customer c)
        {
            c.Latitude = null;
            c.Longitude = null;

            if (string.IsNullOrWhiteSpace(c.Address))
            {
                return;
            }

            try
            {
                var coordinates = _geocoder.GeocodeAddress(c.Address);
                c.Latitude = coordinates.Latitude;
                c.Longitude = coordinates.Longitude;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error while geocoding addresss {0} /nError: {1}", c.Address, e.Message);
            }
        }
Exemplo n.º 42
0
 public void Create(Customer c)
 {
     _db.Customers.Add(c);
     _db.SaveChanges();
 }
Exemplo n.º 43
0
 public void Update(Customer c)
 {
     _db.Entry(c).State = EntityState.Modified;
     _db.SaveChanges();
 }
Exemplo n.º 44
0
        private bool IsNewAddress(Customer customer)
        {
            var previousState = _dao.Customers.Single(c => c.Id == customer.Id);

            return previousState.Address != customer.Address;
        }
Exemplo n.º 45
0
        public Models.Customer newCustomer()
        {
            Models.Customer customer = new Models.Customer();
            var dCustomer = new Data.Customer {
                birthDay = customer.birthDay,
                name = customer.name,
                photoName = customer.photoName,
                timeStamp = customer.timeStamp
            };

            db.customers.Add(dCustomer);
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                httpCtx.Trace.Warn("Database write Error", "Error creating a new Customer", ex);
                return new Models.Customer();
            }

            customer.customerID = dCustomer.customerID;
            routeDiffs(new[]{
                new {
                    op = "add",
                    data = new {
                        orders = new Models.Order[0],
                        products = new Models.Product[0],
                        blobs = new Models.Blob[0],
                        customers = new Models.Customer[] {
                            customer
                        }

                    }
                }
            });
            return customer;
        }