Exemplo n.º 1
0
        // Начисление заработной платы
        public async Task Payroll(OrderServicesCarWashBll order, IEnumerable <OrderCarWashWorkersBll> idBrigade, int serveses)
        {
            OrderCarWashWorkersBll orderCarWashWorkers = new OrderCarWashWorkersBll();

            var resultСortege = CountEmployeesAndCheckPayroll(order, idBrigade);
            var resultDiscont = Discont(order);

            foreach (var item in idBrigade)
            {
                if (resultСortege.Item2 == false)
                {
                    orderCarWashWorkers.IdCarWashWorkers  = item.IdCarWashWorkers;
                    orderCarWashWorkers.IdOrder           = order.Id;
                    orderCarWashWorkers.CalculationStatus = false;
                    orderCarWashWorkers.closedDayStatus   = false;
                    orderCarWashWorkers.typeServicesId    = StatusTypeServises(serveses, 2); // изменить
                }
                else
                {
                    orderCarWashWorkers = item;
                }

                var orderPrice = resultDiscont >= 50 ? order.TotalCostOfAllServices : order.DiscountPrice;
                orderCarWashWorkers.Payroll = await PercentOfTheOrder(item.IdCarWashWorkers, resultСortege.Item1, orderPrice, false, orderCarWashWorkers.typeServicesId.Value);

                await SaveResult(orderCarWashWorkers, resultСortege.Item2);
            }
        }
Exemplo n.º 2
0
        public async Task InsertOrders(int service, List <double> carBody, List <int> id, List <int> sum, double total)
        {
            OrderServicesCarWashBll OrderFormation = new OrderServicesCarWashBll();

            OrderFormation = new OrderServicesCarWashBll
            {
                IdClientsOfCarWash     = OrderServices.idClient,
                StatusOrder            = 1,
                OrderDate              = DateTime.Now,
                TotalCostOfAllServices = _orderServices.OrderPrice(),
                DiscountPrice          = Math.Round(total),
                typeOfOrder            = service
            };

            int orderServicesCar = await CreateOrder(OrderFormation);

            foreach (var item in OrderServices.OrderList)
            {
                _servisesCar = new ServisesCarWashOrderBll
                {
                    IdClientsOfCarWash     = Convert.ToInt32(OrderServices.idClient),
                    IdOrderServicesCarWash = orderServicesCar,
                    IdWashServices         = item.Id,
                    Price = PriceServices(carBody, id, sum, item.Id)
                };

                ServisesCarWashOrder servisesCarWash = Mapper.Map <ServisesCarWashOrderBll, ServisesCarWashOrder>(_servisesCar);

                _unitOfWork.ServisesCarWashOrderUnitOfWork.Insert(servisesCarWash);

                await _unitOfWork.Save();
            }

            _orderServices.ClearListOrder();
        }
Exemplo n.º 3
0
        private double Discont(OrderServicesCarWashBll order)
        {
            double discountPercentage = Convert.ToDouble(order.TotalCostOfAllServices) - Convert.ToDouble(order.DiscountPrice);
            double discontResult      = ((double)discountPercentage / (double)order.TotalCostOfAllServices) * 100;

            return(discontResult);
        }
Exemplo n.º 4
0
        public async Task <int> CreateOrder(OrderServicesCarWashBll orderSave)
        {
            OrderServicesCarWash orderCarWashWorkers = Mapper.Map <OrderServicesCarWashBll, OrderServicesCarWash>(orderSave);

            _unitOfWork.OrderServicesCarWashUnitOfWork.Insert(orderCarWashWorkers);
            await _unitOfWork.Save();

            return(orderCarWashWorkers.Id);
        }
Exemplo n.º 5
0
        // Подсчитать сотрудников, выполняющих заказ
        private (int, bool) CountEmployeesAndCheckPayroll(OrderServicesCarWashBll order, IEnumerable <OrderCarWashWorkersBll> idBrigade)
        {
            int  numberOfEmployees = idBrigade.Count();
            bool checkPayroll      = CheckPayroll(order);

            //numberOfEmployees = checkPayroll ? numberOfEmployees - 1 : numberOfEmployees;
            var result = (numberOfEmployees, checkPayroll);

            return(result);
        }
        private int ClientId(OrderServicesCarWashBll orderServices)
        {
            foreach (var item in orderServices.ServiceColor)
            {
                if (item.clientsOfCarWashId != null)
                {
                    return(item.clientsOfCarWashId.Value);
                }
            }

            return(0);
        }
        private async Task <int> SaveOrderServices(double sum)
        {
            OrderServicesCarWashBll orderServices = new OrderServicesCarWashBll();

            orderServices.StatusOrder  = 1;
            orderServices.PaymentState = 3;

            orderServices.OrderDate = DateTime.Now;
            orderServices.TotalCostOfAllServices = sum;
            orderServices.DiscountPrice          = sum;
            orderServices.typeOfOrder            = (int)TypeService.DryCleaningKohler;

            return(await _orderServices.CreateOrder(orderServices));
        }
Exemplo n.º 8
0
        // выбираем сотрудников с ранее созданого заказа
        public IEnumerable <OrderCarWashWorkersBll> GetCurrentEmployees(OrderServicesCarWashBll order)
        {
            var idBrigade       = new List <OrderCarWashWorkersBll>();
            int statusType      = StatusTypeServises((int)PositionsOfAdministrators.Employees, order.typeOfOrder.Value);
            var employeesResult = order.OrderCarWashWorkers.Where(x => x.typeServicesId == statusType);

            foreach (var item in order.OrderCarWashWorkers) // Пересмотреть реализацию кода
            {
                if (item.typeServicesId == statusType)
                {
                    idBrigade.Add(item);
                }
            }

            return(idBrigade);
        }
Exemplo n.º 9
0
        // Выбор тимлидера и администратора текущей смены для ранее созданого заказа
        public int GetCurrentAdministrator(int idTypeOfOrder, OrderServicesCarWashBll order)
        {
            int statusType = idTypeOfOrder == (int)TypeService.Sales
                ? StatusTypeServises((int)TypeService.Sales, (int)PositionsOfAdministrators.Administrator)
                : StatusTypeServises(order.typeOfOrder.Value, (int)PositionsOfAdministrators.Administrator);

            foreach (var item in order.OrderCarWashWorkers)  // Пересмотреть реализацию кода
            {
                if (item.typeServicesId == statusType)
                {
                    return(item.IdCarWashWorkers);
                }
            }

            return(0);
        }
Exemplo n.º 10
0
        public async Task <int> SaveOrderTireFitting(double Total, double TotalDiscontClient, int idPaymentState, int idStatusOrder, int?Client, int typeOfOrder)
        {
            OrderServicesCarWashBll orderservices = new OrderServicesCarWashBll();

            orderservices.IdClientsOfCarWash     = Client != null ? Client : null;
            orderservices.StatusOrder            = idStatusOrder;
            orderservices.PaymentState           = idPaymentState;
            orderservices.OrderDate              = DateTime.Now;
            orderservices.TotalCostOfAllServices = Total;
            orderservices.DiscountPrice          = TotalDiscontClient;
            orderservices.typeOfOrder            = typeOfOrder;

            if (idPaymentState != 3 && idStatusOrder != 1)
            {
                orderservices.ClosingData = DateTime.Now;
            }

            return(await _orderServices.CreateOrder(orderservices));
        }
Exemplo n.º 11
0
        private async Task ChoiceAdministrator(OrderServicesCarWashBll order, double?orderPrice, bool update)
        {
            OrderCarWashWorkersBll orderCarWashWorkers = new OrderCarWashWorkersBll();

            foreach (var item in order.OrderCarWashWorkers)
            {
                var payroll = item.Payroll;

                if (item.typeServicesId <= 2 || item.typeServicesId == 11)
                {
                    orderCarWashWorkers         = item;
                    orderCarWashWorkers.Payroll = await PercentOfTheOrder(item.CarWashWorkers.id, 1, orderPrice, true, orderCarWashWorkers.typeServicesId.Value);

                    if (item.Payroll == orderCarWashWorkers.Payroll)
                    {
                        await SaveResult(orderCarWashWorkers, update);
                    }
                }
            }
        }
Exemplo n.º 12
0
        // Заработная плата администратора
        public async Task AdminWage(OrderServicesCarWashBll order, int serveses, int idAdmin, bool update = false)
        {
            var servicesOrder = await _servisesCarWash.GetAllId(order.Id);

            var resultDiscont = Discont(order);
            var orderPrice    = resultDiscont >= 50 ? order.TotalCostOfAllServices : order.DiscountPrice;

            bool serviceСategory = servicesOrder.Any(x => x.Detailings.IdTypeService == 1);
            int  adminСategory   = serviceСategory ? 2 : 1; // заменить цифры на enum
            bool checkPayroll    = CheckPayroll(order);

            if (checkPayroll == false)
            {
                await ChoiceAdministrator(adminСategory, order.Id, orderPrice, serveses, idAdmin, update);
            }
            else
            {
                await ChoiceAdministrator(order, orderPrice, update);
            }
        }
Exemplo n.º 13
0
        public async Task RecountOrder(int idOrder, int?ClientDiscont = null)
        {
            OrderServicesCarWashBll WhereIdOrder = await GetId(idOrder);

            OrderServicesCarWash EditOrder = Mapper.Map <OrderServicesCarWashBll, OrderServicesCarWash>(WhereIdOrder);

            var getResult = await _unitOfWork.ServisesCarWashOrderUnitOfWork.GetWhere(x => x.IdOrderServicesCarWash == idOrder);

            EditOrder.TotalCostOfAllServices = getResult.Sum(x => x.Price);

            if (ClientDiscont != null)
            {
                EditOrder.DiscountPrice = _orderServices.Discont(ClientDiscont, EditOrder.TotalCostOfAllServices);
            }
            else
            {
                EditOrder.DiscountPrice = EditOrder.TotalCostOfAllServices;
            }

            _unitOfWork.OrderServicesCarWashUnitOfWork.Update(EditOrder);
            await _unitOfWork.Save();
        }
Exemplo n.º 14
0
        // db Table [OrderServicesCarWash]
        // Закрыть заказ
        public async Task CloseOrder(int idPaymentState, OrderServicesCarWashBll order, int idStatusOrder)
        {
            order.PaymentState = idPaymentState;

            if (idStatusOrder != 4)
            {
                order.ClosingData = DateTime.Now;
            }

            order.StatusOrder = idStatusOrder;

            if (order.ClientsOfCarWash.discont > 0)
            {
                double x = Convert.ToDouble(_orderServices.Discont(order.ClientsOfCarWash.discont, order.TotalCostOfAllServices));
                order.DiscountPrice = Math.Ceiling(x);
            }
            else
            {
                order.DiscountPrice = order.TotalCostOfAllServices;
            }

            await _orderServicesCarWash.SaveOrder(order);
        }
Exemplo n.º 15
0
        public async Task <int> OrderForCarpetCleaning(OrderCarpetWashingBll orderCarpetWashing, int?idPaymentState, int prise, int clientId)
        {
            double?sumOrder      = orderCarpetWashing.area * (double)prise;
            var    resultClients = await _clientsOfCarWashServices.ClientWhereToInfoClient(clientId);

            OrderServicesCarWashBll orderservices = new OrderServicesCarWashBll();

            if (resultClients != null)
            {
                orderservices = new OrderServicesCarWashBll
                {
                    StatusOrder            = 1,
                    OrderDate              = orderCarpetWashing.orderDate,
                    IdClientsOfCarWash     = resultClients.id,
                    TotalCostOfAllServices = sumOrder,
                    DiscountPrice          = sumOrder,
                    typeOfOrder            = 3,
                    PaymentState           = idPaymentState
                };
            }
            else
            {
                orderservices = new OrderServicesCarWashBll
                {
                    StatusOrder            = 1,
                    OrderDate              = orderCarpetWashing.orderDate,
                    IdClientsOfCarWash     = null,
                    TotalCostOfAllServices = sumOrder,
                    DiscountPrice          = sumOrder,
                    typeOfOrder            = 3,
                    PaymentState           = idPaymentState
                };
            }


            return(await _orderServicesCarWash.CreateOrder(orderservices));
        }
 private async Task SaveOrderServices(OrderServicesCarWashView orderServices)
 {
     OrderServicesCarWashBll orderServicesBll = Mapper.Map <OrderServicesCarWashView, OrderServicesCarWashBll>(orderServices);
     await _orderServicesCarWash.SaveOrder(orderServicesBll);
 }
Exemplo n.º 17
0
 public async Task SaveOrder(OrderServicesCarWashBll orderSave)
 {
     _unitOfWork.OrderServicesCarWashUnitOfWork.Update(EntityTransformation(orderSave));
     await _unitOfWork.Save();
 }
Exemplo n.º 18
0
 private OrderServicesCarWash EntityTransformation(OrderServicesCarWashBll Entity) =>
 Mapper.Map <OrderServicesCarWashBll, OrderServicesCarWash>(Entity);
Exemplo n.º 19
0
 private bool CheckPayroll(OrderServicesCarWashBll order)
 => order.OrderCarWashWorkers.Any();