Exemplo n.º 1
0
        public async Task <IHttpActionResult> Post(CreateOrderModel model)
        {
            var memberId = User.GetMemberId();
            var request  = new OpenOrderRequest(memberId, model.FromUnitId, model.ItemId, model.Remarks);

            return(await Dispatch(request, async r => {
                return await queryService.GetOrderOverview(r.OrderId);
            }));
        }
Exemplo n.º 2
0
        public async Task <Result <OrderProblemSent> > Handle(SendOrderProblemRequest request)
        {
            var member = await appQueryService.GetMember(request.MemberId);

            var order = await appQueryService.GetOrderOverview(request.OrderId);

            var error = Validate(member, order);

            if (error != null)
            {
                return(error);
            }


            var solvers = await appQueryService.GetProblemSolvers();

            if (solvers.Length == 0)
            {
                return(new OrderProblemSent());
            }

            var mailBody = GenerateMailBody(member, order, request.Description);

            foreach (var solver in solvers)
            {
                var mailRequest = new MailRequest
                {
                    Body    = mailBody,
                    From    = "*****@*****.**",
                    IsHtml  = true,
                    Subject = $"נפתחה בעייה כבור הזמנה {order.Id}",
                    To      = solver.Email
                };
                mailService.Send(mailRequest);
            }


            return(new OrderProblemSent());
        }