Beispiel #1
0
        public IHttpActionResult PostOrderDetails(OrderDetailsDto orderDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _orderDetailsService.Add(orderDetails);

            return(CreatedAtRoute("DefaultApi", new { id = orderDetails.OrderId }, orderDetails));
        }
Beispiel #2
0
        public async Task <IActionResult> CreateAsync(CustomerOrderViewModel model)
        {
            double tot = model.TotalAmount;
            double rec = model.ReceiptMonay;
            double rem = tot - rec;

            if (model.CustomerId != 0)
            {
                if (ModelState.IsValid)
                {
                    Order order = new Order
                    {
                        CategoryId  = model.CategoryId,
                        ReceiptDate = model.ReceiptDate,
                        CustomerId  = model.CustomerId,
                        //OrderDetailsId = model.Id,
                        AddedByUser = _signInManager.UserManager.GetUserId(User),
                        ModifiedAt  = DateTime.Now,
                    };
                    await _orderService.Add(order);

                    OrderDetails orderDetails = new OrderDetails
                    {
                        CustomerName        = model.FullName,
                        DarperyNeededLength = model.DarperyNeededLength,
                        Longness            = model.Longness,
                        Neck          = model.Neck,
                        Shoulder      = model.Shoulder,
                        Side          = model.Side,
                        SleeveLength  = model.SleeveLength,
                        Phone         = model.CustomerPhone,
                        Quantity      = model.Quntity,
                        TotalAmount   = model.TotalAmount,
                        ReceiptMonay  = model.ReceiptMonay,
                        RemanentMonay = rem,
                        Sleevewasae   = model.Sleevewasae,
                        DraperyFrom   = model.DraperyFrom,
                        CreatedAt     = model.CreatedAt,
                        ReceiptDate   = model.ReceiptDate,
                        CustomerType  = model.CustomerType,
                        OrderId       = order.Id,

                        AddedByUser = _signInManager.UserManager.GetUserId(User),
                        ModifiedAt  = DateTime.Now
                    };

                    await _orderDetailsService.Add(orderDetails);
                }
                ;
                TempData["message"] = "تم إضافة الطلب بنجاح!";
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    Order order = new Order
                    {
                        CategoryId  = model.CategoryId,
                        ReceiptDate = model.ReceiptDate,
                        AddedByUser = _signInManager.UserManager.GetUserId(User),
                        ModifiedAt  = DateTime.Now,
                    };
                    await _orderService.Add(order);

                    OrderDetails orderDetails = new OrderDetails
                    {
                        CustomerName        = model.FullName,
                        DarperyNeededLength = model.DarperyNeededLength,
                        Longness            = model.Longness,
                        Neck          = model.Neck,
                        Shoulder      = model.Shoulder,
                        Side          = model.Side,
                        SleeveLength  = model.SleeveLength,
                        Phone         = model.CustomerPhone,
                        Quantity      = model.Quntity,
                        TotalAmount   = model.TotalAmount,
                        ReceiptMonay  = model.ReceiptMonay,
                        RemanentMonay = rem,
                        Sleevewasae   = model.Sleevewasae,
                        DraperyFrom   = model.DraperyFrom,
                        CreatedAt     = model.CreatedAt,
                        ReceiptDate   = model.ReceiptDate,
                        CustomerType  = model.CustomerType,
                        OrderId       = order.Id,

                        AddedByUser = _signInManager.UserManager.GetUserId(User),
                        ModifiedAt  = DateTime.Now
                    };

                    await _orderDetailsService.Add(orderDetails);
                }
                ;
            }
            TempData["message"] = "تم إضافة الطلب بنجاح!";
            return(RedirectToAction(nameof(Index)));
        }