Пример #1
0
        public virtual ActionResult Index(int currentPage = 1, int itemsPerPage = 15)
        {
            if (currentPage < 1) currentPage = 1;
            if (itemsPerPage < 1) itemsPerPage = 1;

            using (var rdbc = new RavenDbConnection(new RavenDbConnectionManager()))
            {
                var service = new ClientService(rdbc);
                var clients = service.GetClients(currentPage, itemsPerPage);
                var clientViewModels = new List<ClientEditViewModel>(clients.Results.Count);
                clientViewModels.AddRange(clients.Results.Select(client => new ClientEditViewModel(client)));

                var clientHomeViewModel = new ClientHomeViewModel
                {
                    Clients = clientViewModels,
                    CurrentPage = currentPage,
                    ItemsPerPage = itemsPerPage
                };
                foreach (var downServer in clients.ErrorConnectionStrings)
                {
                    clientHomeViewModel.AddDownServers(downServer);
                }
                return View(clientHomeViewModel);
            }
        }
Пример #2
0
 public virtual ActionResult Index(ClientEditViewModel clientEditViewModel)
 {
     using (var ravenDbConnection = new RavenDbConnection(new RavenDbConnectionManager()))
     {
         var service = new ClientService(ravenDbConnection);
         service.UpdateClient(clientEditViewModel.Id, clientEditViewModel.FirstName, clientEditViewModel.LastName, clientEditViewModel.Country);
         return RedirectToAction("Index", "Home");
     }
 }
Пример #3
0
        public virtual ActionResult Index(string id)
        {
            using (var ravenDbConnection = new RavenDbConnection(new RavenDbConnectionManager()))
            {
                var service = new ClientService(ravenDbConnection);
                service.DeleteClient(id);
            }

            return RedirectToAction("Index", "Home");
        }
Пример #4
0
 //
 // GET: /Edit/
 public ActionResult Index(string id)
 {
     using (var ravenDbConnection = new RavenDbConnection(new RavenDbConnectionManager()))
     {
         var service = new ClientService(ravenDbConnection);
         var client = service.GetClient(id);
         var viewModel = new ClientEditViewModel(client);
         return View(viewModel);
     }
 }
Пример #5
0
 public virtual ActionResult Index(ClientEditViewModel clientEdit)
 {
     try
     {
         using (var ravenDbConnection = new RavenDbConnection(new RavenDbConnectionManager()))
         {
             var service = new ClientService(ravenDbConnection);
             service.AddClient(clientEdit.FirstName, clientEdit.LastName, clientEdit.Country);
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return RedirectToAction("Index", "Home");
     }
 }
Пример #6
0
        public ActionResult AddOrder(OrdersAddViewModel order)
        {
            using (var rdbc = new RavenDbConnection(_rdcm))
            {
                var orderService = new OrderService(rdbc);
                var clientService = new ClientService(rdbc);
                var client = clientService.GetClient(order.ClientId);

                var newOrder = new Order
                {
                    ClientId = client.Id,
                    ClientFirstName = client.FirstName,
                    ClientLastName = client.LastName,
                    ClientCountry = client.Country,
                    Payments = new List<Payment>
                    {
                        new Payment
                        {
                            Amount = order.PaymentAmount,
                            Id = order.PaymentId
                        }
                    },
                    Products = new List<Product>
                    {
                        new Product
                        {
                            Name = order.ProductName,
                            Price = order.ProductPrice
                        }
                    },
                    TimeOfOrder = DateTime.Now
                };
                orderService.AddOrder(newOrder);
            }
            return RedirectToAction("Index", "Home");
        }
Пример #7
0
 public UserRegistrationService()
 {
     _clientService = new ClientService();
     _userService   = new UserService();
 }