コード例 #1
0
        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");
        }
コード例 #2
0
        public ActionResult Add()
        {
            Models.Customer m = new Models.Customer();
            m.CreateTime = DateTime.Now;
            m.Age = 30;

            return View(m);
        }
コード例 #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;
            }
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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 = "" }));
        }
コード例 #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");
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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));
     }
 }
コード例 #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));
        }
コード例 #13
0
ファイル: OrderController.cs プロジェクト: jacobstilin/Kafe
        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()));
        }
コード例 #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"));
        }
コード例 #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"));
        }
コード例 #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());
        }
コード例 #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;
        }
コード例 #18
0
        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());
            }
        }
コード例 #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"));
        }
コード例 #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());
     }
 }
コード例 #21
0
        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));
            }
        }
コード例 #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);
        }
コード例 #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"));
            }
        }
コード例 #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"));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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"));
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #31
0
ファイル: OrderController.cs プロジェクト: jacobstilin/Kafe
        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
        }
コード例 #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
     });
 }
コード例 #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();
            }
        }
コード例 #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));
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #37
0
        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;
        }
コード例 #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));
        }
コード例 #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();
            }
        }
コード例 #40
0
ファイル: DAL.cs プロジェクト: spikk/effective-adventure
        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;

        }
コード例 #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);
            }
        }
コード例 #42
0
ファイル: CustomerDao.cs プロジェクト: danieleli/BetterCloud
 public void Create(Customer c)
 {
     _db.Customers.Add(c);
     _db.SaveChanges();
 }
コード例 #43
0
ファイル: CustomerDao.cs プロジェクト: danieleli/BetterCloud
 public void Update(Customer c)
 {
     _db.Entry(c).State = EntityState.Modified;
     _db.SaveChanges();
 }
コード例 #44
0
        private bool IsNewAddress(Customer customer)
        {
            var previousState = _dao.Customers.Single(c => c.Id == customer.Id);

            return previousState.Address != customer.Address;
        }
コード例 #45
0
ファイル: DataAccess.cs プロジェクト: ziahamza/Wirecraft
        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;
        }