Пример #1
0
 public void Update(Customer cus)
 {
     using (var client = new HttpClient())
     {
         HttpResponseMessage response =
             client.PutAsJsonAsync(ServerAddress.Address + "customer/", cus).Result;
     }
 }
Пример #2
0
 public void Remove(Customer cus)
 {
     using (var client = new HttpClient())
     {
         HttpResponseMessage response =
             client.DeleteAsync(ServerAddress.Address + "customer/" + cus.Id).Result;
     }
 }
Пример #3
0
 public List<Order> GetOrdersByCustomer(Customer cus)
 {
     using (var client = new HttpClient())
     {
         HttpResponseMessage response =
             client.GetAsync(ServerAddress.Address + "ordersbycustomer?id="+cus.Id).Result;
         return response.Content.ReadAsAsync<List<Order>>().Result;
     }
 }
 public ActionResult Create(Customer Customer)
 {
     int Year = Convert.ToInt32(Customer.BirthDate.Year);
     int Month = Convert.ToInt32(Customer.BirthDate.Month);
     int Day = Convert.ToInt32(Customer.BirthDate.Day);
     Customer.BirthDate = new DateTime(Year, Month, Day);
     facade.GetCustomerRep().Add(Customer);
     return Redirect("index");
 }
Пример #5
0
 public ActionResult PlaceOrder(Customer cus)
 {
     if (cus.Id == 0)
         Facade.GetInstance().GetCustomerRep().Add(cus);
     Order order = new Order() { Customer = cus, Date = DateTime.Now, OrderMovie = new List<OrderMovie>() };
     Facade.GetInstance().GetOrderRep().Add(order);
     foreach (var item in ShoppingCart.GetInstance().movies)
     {
         OrderMovie om = new OrderMovie() { Movie = item, Order = order };
         Facade.GetInstance().GetOrderMovieRep().Add(om);
     }
     ShoppingCart.GetInstance().EmptyCart();
     SetCart();
     return View();
 }
Пример #6
0
        public void Customer_saved_to_db_on_create_test()
        {
            Customer cos = new Customer()
            {
                Id = 1,
                Address = "Address1",
                BirthDate = DateTime.Now,
                Email = "Email1",
                FirstName = "Jonas",
                LastName = "Olesen",
                PhoneNumber = 22755692
            };

            Context context = new Context();
            context.Customers.Add(cos);
            context.SaveChanges();

            Context context2 = new Context();
            Assert.AreEqual(context2.Customers.FirstOrDefault(x => x.Id == cos.Id).FirstName, cos.FirstName);
            Assert.AreEqual(context2.Customers.FirstOrDefault(x => x.Id == cos.Id).LastName, cos.LastName);
            Assert.AreEqual(context2.Customers.FirstOrDefault(x => x.Id == cos.Id).Email, cos.Email);
            Assert.AreEqual(context2.Customers.FirstOrDefault(x => x.Id == cos.Id).PhoneNumber, cos.PhoneNumber);
            Assert.AreEqual(context2.Customers.FirstOrDefault(x => x.Id == cos.Id).Address, cos.Address);
        }
Пример #7
0
 public ActionResult UpdateUserPost(Login login, Customer customer)
 {
     Facade.GetInstance().GetCustomerRep().Update(customer);
     if (login.Password == null)
         login.Password = Facade.GetInstance().GetLoginRep().GetAllLogins().Where(x => x.Username.Equals(login.Username)).FirstOrDefault().Password;
     Facade.GetInstance().GetLoginRep().Update(login);
     login.Customer = customer;
     ShoppingCart.GetInstance().login = login;
     return RedirectToAction("Index", "Home");
 }
Пример #8
0
        public ActionResult Register(Login login,Customer customer, string returnUrl)
        {
            if (Facade.GetInstance().GetLoginRep().GetAllLogins().Where(x => x.Username.Equals(login.Username)).FirstOrDefault() != null)
            {
                ShoppingCart.GetInstance().UsernameExist = true;
                return Redirect(returnUrl);
            }
            if (Facade.GetInstance().GetLoginRep().GetAllLogins().Where(x => x.Customer.Email.Equals(customer.Email)).FirstOrDefault() != null)
            {
                ShoppingCart.GetInstance().EmailExist = true;
                return Redirect(returnUrl);
            }

            login.Customer = customer;
            Facade.GetInstance().GetLoginRep().Add(login);
            return Login(login, returnUrl);
        }