public virtual ActionResult AddSalesOrder(SalesOrderDetailDto dto)
        {
            string alertMessage = string.Empty, salesOrder = string.Empty;
            bool   isSuccess = true;
            List <SalesOrderDetailDto> listOfOrders = new List <SalesOrderDetailDto>();

            var inventoryList = _inventoryService.FindByProductId(dto.ProductID);
            var unitList      = _unitService.FindUnitById((int)dto.UnitID);

            if (inventoryList.IsNull())
            {
                isSuccess = false;
                Danger(Messages.NoProductFound);
            }
            else
            {
                if (!dto.IsNull())
                {
                    listOfOrders.Add(new SalesOrderDetailDto()
                    {
                        ProductID   = dto.ProductID,
                        ProductCode = inventoryList == null ? string.Empty : inventoryList.ProductCode,
                        ProductName = inventoryList == null ? string.Empty : inventoryList.ProductName,
                        ProductExt  = inventoryList == null ? string.Empty : inventoryList.ProductExtension,
                        UnitID      = dto.UnitID,
                        UnitDesc    = unitList == null ? string.Empty : unitList.UnitDesc,
                        UnitPrice   = dto.UnitPrice,
                        Quantity    = dto.Quantity
                    });
                    isSuccess  = true;
                    salesOrder = this.RenderRazorViewToString(IOBALANCEMVC.OrderManagement.SalesOrder.Views._ListOfOrderSales, listOfOrders);
                }
            }



            alertMessage = this.RenderRazorViewToString(IOBALANCEMVC.Shared.Views._Alerts, string.Empty);
            var jsonResult = new
            {
                isSuccess    = isSuccess,
                alertMessage = alertMessage,
                salesOrder   = salesOrder
            };

            return(Json(jsonResult, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public static IOBalanceDBV2Entity.SalesOrderDetail DtoToEntity(this SalesOrderDetailDto dto)
        {
            IOBalanceDBV2Entity.SalesOrderDetail entity = null;

            if (!dto.IsNull())
            {
                entity = new IOBalanceDBV2Entity.SalesOrderDetail
                {
                    SalesOrderID = dto.SalesOrderId,
                    ProductID    = dto.ProductId,
                    SalesPrice   = dto.SalesPrice,
                    UnitPrice    = dto.UnitPrice,
                    Quantity     = dto.Quantity,
                    DateCreated  = dto.DateCreated,
                    CreatedBy    = dto.CreatedBy
                };
            }

            return(entity);
        }