Exemplo n.º 1
0
        //GET: Manage/AddressDelete
        public ActionResult AddressDelete(int id)
        {
            var customerWorker = new CustomerWorker();

            customerWorker.DeleteCustomerAddress(id);
            return(RedirectToAction("Address"));
        }
        // GET: Admin/Order/Detail
        public ActionResult Detail(int id)
        {
            try
            {
                ViewBag.Id = id;

                var orderWorker = new OrderWorker();
                var paymentWorker = new PaymentWorker();
                var customerWorker = new CustomerWorker();

                var model = orderWorker.GetManagerOrderEdit(id);
                var paymodel = paymentWorker.GetManagerPaymentEntitiesByOrder(id);
            
                ViewBag.User = customerWorker.GetCustomerUser(model.Customer.UserId);

                ViewBag.Statuses = SmartBazaar.Web.Models.Common.OrderHeadsListProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString(), Selected = s.Key == model.Status }).AsEnumerable();
                if (paymodel != null)
                {
                    ViewBag.Payment = paymodel;
                    ViewBag.PayId = paymodel.Id;
                    ViewBag.PayStatuses = SmartBazaar.Web.Models.Common.PaymentEntitiesListsProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString(), Selected = s.Key == paymodel.Status });
                }
                else
                {
                    ViewBag.PayStatuses = SmartBazaar.Web.Models.Common.PaymentEntitiesListsProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString()});
                }

                return View(model);
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
                return null;
            }
        }
Exemplo n.º 3
0
        // GET: /Manage/Address
        public ActionResult Address(int page = 1, short Status = 1)
        {
            var customerWorker = new CustomerWorker();

            ViewBag.CurrentPage = page;
            ViewBag.Status      = Status;
            var records = customerWorker.GetSiteCustomerAddresses(CustomerLayer.Customer.Id, Status);

            ViewBag.TotalPage = records.Count;
            var model = records.OrderBy(o => o.Id).Skip((page - 1) * AppConfig.PAGE_SIZE).Take(AppConfig.PAGE_SIZE);

            return(View(model));
        }
Exemplo n.º 4
0
        //GET: Commit
        public ActionResult Commit(int id)
        {
            var orderLayer = new OrderLayer();

            string orderMail      = this.RenderRazorView("Mails/Order", orderLayer.Order);
            var    customerWorker = new CustomerWorker();
            var    customerUser   = customerWorker.GetCustomerUser(CustomerLayer.Customer.Id.ToString());
            var    mailer         = new Khaled.SmtpClient.SmtpMailClient();

            mailer.PostMail(ConfigurationManager.AppSettings["AdminEmail"], "Sipariş", orderMail);
            BasketLayer.RemoveAll();

            ViewBag.Method = id;

            return(View(orderLayer.Order));
        }
Exemplo n.º 5
0
        //GET: Manage/AddressEdit
        public ActionResult AddressEdit(int id)
        {
            var customerWorker = new CustomerWorker();
            var model          = customerWorker.GetSiteCustomerAddress(id);

            List <Models.Internal.CityModel> cities = LocationWalker.GetCities();

            ViewBag.Cities = cities.Select(s => new SelectListItem {
                Value = s.Id.ToString(), Text = s.Title, Selected = s.Title == model.City
            });
            ViewBag.Districts = LocationWalker.GetDistrict(cities.FirstOrDefault(f => f.Title == model.City).Id).Select(s => new SelectListItem {
                Value = s.Title, Text = s.Title, Selected = s.Title == model.District
            });

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Checkout(FormCollection frm)
        {
            var shipmentWorker = new ShipmentWorker();
            var paymentWorker  = new PaymentWorker();
            var customerWorker = new CustomerWorker();
            var orderLayer     = new OrderLayer();

            if (frm["AddressId"] != null)
            {
                orderLayer.Order.ShipAddressId = int.Parse(frm["AddressId"]);
                if (frm["InvoiceSendPartial"] == "yes")
                {
                    orderLayer.Order.InvoiceAddressId = int.Parse(frm["InvoiceAddressId"]);
                }
                else
                {
                    orderLayer.Order.InvoiceAddressId = int.Parse(frm["AddressId"]);
                }
            }

            orderLayer.Order.ShipmentTypeId = int.Parse(frm["ShipmentType"]);
            orderLayer.Order.Note           = frm["Note"];

            if (orderLayer.Order.ShipCost == 0)
            {
                decimal shipCost = ShippingHelper.ShippingPrice(shipmentWorker.GetSiteShipmentType(orderLayer.Order.ShipmentTypeId));
                orderLayer.Order.TaxTotal   += shipCost * 18 / 118;
                orderLayer.Order.ShipCost    = shipCost * 100 / 118;
                orderLayer.Order.GrandTotal += shipCost;
            }

            orderLayer.Sync();
            orderLayer.Order.Payments = paymentWorker.GetSitePaymentTypes();

            ViewBag.ShipmentType = shipmentWorker.GetSiteShipmentType(orderLayer.Order.ShipmentTypeId);
            if (orderLayer.Order.ShipAddressId.HasValue)
            {
                ViewBag.ShipmentAddress = customerWorker.GetSiteCustomerAddress(orderLayer.Order.ShipAddressId.Value);
            }

            if (frm["InvoiceSendPartial"] == "yes")
            {
                ViewBag.InvoiceAddress = customerWorker.GetSiteCustomerAddress(orderLayer.Order.InvoiceAddressId.Value);
            }

            return(View(orderLayer.Order));
        }
Exemplo n.º 7
0
 public ActionResult AddressEdit(Models.Site.CustomerAddressViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.City = LocationWalker.GetCities().FirstOrDefault(f => f.Id == int.Parse(model.City)).Title;
         var customerWorker = new CustomerWorker();
         customerWorker.UpdateSiteCustomerAddress(model);
         return(RedirectToAction("Address"));
     }
     ViewBag.Cities = LocationWalker.GetCities().Select(s => new SelectListItem {
         Value = s.Id.ToString(), Text = s.Title
     });
     ViewBag.Districts = LocationWalker.GetDistrict(int.Parse(model.City)).Select(s => new SelectListItem {
         Value = s.Title, Text = s.Title
     });
     return(View(model));
 }
Exemplo n.º 8
0
        //GET: Begin
        public ActionResult Begin()
        {
            var customerWorker = new CustomerWorker();
            var shipmentWorker = new ShipmentWorker();

            ViewBag.Cities = LocationWalker.GetCities().Select(s => new SelectListItem {
                Value = s.Id.ToString(), Text = s.Title
            });
            ViewBag.Districts = LocationWalker.GetDistrict(1).Select(s => new SelectListItem {
                Value = s.Id.ToString(), Text = s.Title
            });

            var orderLayer = OrderLayer.Create();

            orderLayer.Order.Addresses = customerWorker.GetSiteCustomerAddresses(CustomerLayer.Customer.Id, 1);
            orderLayer.Order.Shipments = shipmentWorker.GetSiteShipmentTypes();

            return(View(orderLayer.Order));
        }
Exemplo n.º 9
0
        public ActionResult AddAddress(FormCollection frm)
        {
            var model = new CustomerAddressViewModel
            {
                CustomerId = CustomerLayer.Customer.Id,
                City       = LocationWalker.GetCities().FirstOrDefault(f => f.Id == int.Parse(frm["AddressCity"])).Title,
                Detail     = frm["AddressDetail"],
                District   = frm["AddressDistrict"],
                IsDefault  = false,
                PostalCode = frm["AddressPostalCode"],
                Status     = 1,
                Title      = frm["AddressTitle"],
                Town       = frm["AddressTown"]
            };
            CustomerWorker customerWorker = new CustomerWorker();

            customerWorker.InsertSiteCustomerAddress(model);

            return(RedirectToAction("Begin"));
        }
Exemplo n.º 10
0
        public void Search()
        {
            // Arrange
            ICustomerWorker customerWorker = new CustomerWorker();
            string          document       = GenerateRandomNumber().ToString();
            CustomerDto     customerDto    = new CustomerDto()
            {
                Document  = document,
                Email     = "*****@*****.**",
                FirtsName = "Carl",
                LastName  = "Sagan",
                Phone     = "7889"
            };

            // ACT
            customerWorker.Create(customerDto);
            var custumer = customerWorker.Search(document);

            // Assert
            Assert.AreEqual(custumer.FirtsName, customerDto.FirtsName, "No se encontró el cliente");
        }
Exemplo n.º 11
0
        public void Create()
        {
            // Arrange
            ICustomerWorker customerWorker = new CustomerWorker();
            string          document       = GenerateRandomNumber().ToString();
            CustomerDto     customerDto    = new CustomerDto()
            {
                Document  = document,
                Email     = "*****@*****.**",
                FirtsName = "Peter",
                LastName  = "Parker",
                Phone     = "10101010"
            };

            // ACT
            customerWorker.Create(customerDto);

            // Assert
            var custumer = customerWorker.Search(document);

            Assert.AreEqual(custumer.FirtsName, customerDto.FirtsName, "No se inserto correctamente");
        }
Exemplo n.º 12
0
        public void ChangeState()
        {
            // Arrange
            ICustomerWorker customerWorker = new CustomerWorker();
            string          document       = GenerateRandomNumber().ToString();
            CustomerDto     customerDto    = new CustomerDto()
            {
                Document  = document,
                Email     = "*****@*****.**",
                FirtsName = "Laura",
                LastName  = "Lopez",
                Phone     = "1239303"
            };

            // ACT
            customerWorker.Create(customerDto);
            customerWorker.ChangeState(customerDto.Document, false);

            // Assert
            var custumer = customerWorker.Search(document);

            Assert.AreEqual(custumer.Enable, customerDto.Enable, "No se cambio el estado correctamente");
        }
Exemplo n.º 13
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                Guid userId = Guid.NewGuid();
                var  user   = new ApplicationUser {
                    Id = userId.ToString(), UserName = model.Email, Email = model.Email, EmailConfirmed = true
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var customerWorker = new CustomerWorker();
                    model.Customer.UserId = userId.ToString();
                    customerWorker.CustomerRegister(model.Customer);
                    customerWorker = null;

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            this.Pair2List <RegisterViewModel, short, short>(Models.Common.CustomerEntityListProvider.GetCustomerTypeList(), m => m.Customer.CustomerType, "1");
            ViewBag.Gender = Models.Common.CustomerEntityListProvider.GetGenderList().Select(item => new SelectListItem {
                Text = item.Value, Value = item.Key.ToString()
            }).ToList();
            return(View(model));
        }
Exemplo n.º 14
0
        public void Update()
        {
            // Arrange
            ICustomerWorker customerWorker = new CustomerWorker();
            string          document       = GenerateRandomNumber().ToString();
            CustomerDto     customerDto    = new CustomerDto()
            {
                Document  = document,
                Email     = "*****@*****.**",
                FirtsName = "Luisa",
                LastName  = "Lane",
                Phone     = "222222222"
            };

            // ACT
            customerWorker.Create(customerDto);
            customerDto.Phone = "3333333";
            customerWorker.Update(customerDto);

            // Assert
            var custumer = customerWorker.Search(document);

            Assert.AreEqual(custumer.Phone, customerDto.Phone, "No se actualizo correctamente");
        }
Exemplo n.º 15
0
 public CustomerManagerController()
 {
     m_customerWorker = new CustomerWorker();
 }