示例#1
0
        public CustomerModel GetCustomer(int id)
        {
            try
            {
                IEnumerable <int> listOfIds = _salonManager.GetIds();

                if (listOfIds.Contains(id))
                {
                    CustomerEntity selectedCustomer = _salonManager.GetSingle(id);

                    CustomerModel customerViewModel = new CustomerModel
                    {
                        Id          = selectedCustomer.Id,
                        FirstName   = selectedCustomer.FirstName,
                        LastName    = selectedCustomer.LastName,
                        PhoneNumber = selectedCustomer.PhoneNumber,
                        Email       = selectedCustomer.Email
                    };

                    return(customerViewModel);
                }
                else
                {
                    throw new Exception($"Customer with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#2
0
        public ServiceModel GetService(int id)
        {
            try
            {
                IEnumerable <int> listOfIds = _salonManager.GetIds();

                if (listOfIds.Contains(id))
                {
                    ServiceEntity selectedService = _salonManager.GetSingle(id);

                    ServiceModel serviceViewModel = new ServiceModel
                    {
                        Id            = selectedService.Id,
                        NameOfService = selectedService.NameOfService,
                        Price         = selectedService.Price
                    };

                    return(serviceViewModel);
                }
                else
                {
                    throw new Exception($"Service with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#3
0
        public OrderModel GetOrder(int id)
        {
            try
            {
                IEnumerable <int> listOfIds = _orderManager.GetIds();

                if (listOfIds.Contains(id))
                {
                    OrderEntity selectedOrder = _orderManager.GetSingle(id);

                    CustomerEntity customer = _customerManager.GetSingle(selectedOrder.CustomerId);
                    ServiceEntity  service  = _serviceManager.GetSingle(selectedOrder.ServiceId);
                    StateEntity    state    = _stateManager.GetSingle(selectedOrder.StatusId);

                    OrderModel orderViewModel = new OrderModel
                    {
                        Id       = selectedOrder.Id,
                        Customer = new CustomerModel
                        {
                            Id          = customer.Id,
                            FirstName   = customer.FirstName,
                            LastName    = customer.LastName,
                            PhoneNumber = customer.PhoneNumber,
                            Email       = customer.Email
                        },
                        Service = new ServiceModel
                        {
                            Id            = service.Id,
                            NameOfService = service.NameOfService,
                            Price         = service.Price
                        },
                        Price  = service.Price,
                        Date   = selectedOrder.DateOfProcedure,
                        Status = new StateModel
                        {
                            Id          = state.Id,
                            OrderStatus = state.OrderStatus
                        }
                    };

                    return(orderViewModel);
                }
                else
                {
                    throw new Exception($"Order with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }