Ejemplo n.º 1
0
        public void FinishOrder(ChangeStatusBindingModel model)
        {
            var order = orderLogic.Read(new OrderBindingModel {
                Id = model.OrderId
            })?[0];

            if (order == null)
            {
                throw new Exception("Не найден заказ");
            }
            if (order.Status != OrderStatus.Выполняется)
            {
                throw new Exception("Заказ не в статусе \"Выполняется\"");
            }
            orderLogic.CreateOrUpdate(new OrderBindingModel
            {
                Id            = order.Id,
                ClientId      = order.ClientId,
                KomlectId     = order.KomlectId,
                ImplementerId = order.ImplementerId,
                Count         = order.Count,
                Sum           = order.Sum,
                DateCreate    = order.DateCreate,
                DateImplement = order.DateImplement,
                Status        = OrderStatus.Готов
            });
            MailLogic.MailSendAsync(new MailSendInfo
            {
                MailAddress = clientLogic.Read(new ClientBindingModel {
                    Id = order.ClientId
                })?[0]?.Email,
                Subject = $"Заказ №{order.Id}",
                Text    = $"Заказ №{order.Id} готов."
            });
        }
Ejemplo n.º 2
0
        public void TakeOrderInWork(ChangeStatusBindingModel model)
        {
            lock (locker)
            {
                var order = orderLogic.Read(new OrderBindingModel {
                    Id = model.OrderId
                })?[0];

                if (order == null)
                {
                    throw new Exception("Не найден заказ");
                }
                if (order.Status != OrderStatus.Принят)
                {
                    throw new Exception("Заказ не в статусе \"Принят\"");
                }
                if (order.ImplementerId.HasValue)
                {
                    throw new Exception("У заказа уже есть исполнитель");
                }
                orderLogic.CreateOrUpdate(new OrderBindingModel
                {
                    Id            = order.Id,
                    ClientId      = order.ClientId,
                    KomlectId     = order.KomlectId,
                    ImplementerId = model.ImplementerId,
                    Count         = order.Count,
                    Sum           = order.Sum,
                    DateCreate    = order.DateCreate,
                    DateImplement = DateTime.Now,
                    Status        = OrderStatus.Выполняется
                });
                MailLogic.MailSendAsync(new MailSendInfo
                {
                    MailAddress = clientLogic.Read(new ClientBindingModel {
                        Id = order.ClientId
                    })?[0]?.Email,
                    Subject = $"Заказ №{order.Id}",
                    Text    = $"Заказ №{order.Id} передан в работу."
                });
            }
        }
Ejemplo n.º 3
0
 public void CreateOrder(CreateOrderBindingModel model)
 {
     orderLogic.CreateOrUpdate(new OrderBindingModel
     {
         KomlectId  = model.KomlectId,
         ClientId   = model.ClientId,
         Count      = model.Count,
         Sum        = model.Sum,
         DateCreate = DateTime.Now,
         Status     = OrderStatus.Принят
     });
     MailLogic.MailSendAsync(new MailSendInfo
     {
         MailAddress = clientLogic.Read(new ClientBindingModel {
             Id = model.ClientId
         })?[0]?.Email,
         Subject = $"Новый заказ",
         Text    = $"Заказ принят."
     });
 }