Beispiel #1
0
        public async Task <string> ConfirmPurchase(string purchaseId)
        {
            var purchase = await po.findPurchaseOrderByIdAsync(purchaseId);

            var purchasedt = (await po.findPurchaseOrderDetailbypIdAsync(purchase.ReplyId)).SingleOrDefault();
            var product    = await itm.findItembyIdAsync(purchasedt.ItemId);

            var wholesaler = await ws.findWholesalerByIdAsync(purchase.WholesalerId);

            ServiceReference_Invoice.Invoice invoice = new ServiceReference_Invoice.Invoice();
            purchase.StatusPurchase = "confirmed";
            purchase.StatusInquiry  = "Readed";
            bool res = await po.updatePurchaseOrderAsync(purchase);

            if (res)
            {
                invoice.InvoiceId = await iv.getInvoiceIdAsync(purchaseId);

                invoice.PurchaseOrderId = purchase.ReplyId;
                invoice.SupplierId      = product.SupplierId;
                invoice.WholesalerId    = purchase.WholesalerId;
                invoice.EmloyeeID       = 1;
                invoice.InvoiceDate     = DateTime.Now;
                invoice.PaymentMethodId = 1;
                invoice.Status          = "unpaid";
                invoice.ShipFee         = 0;
                invoice.ShipAddress     = wholesaler.AddressWS;
                invoice.Total           = (double)purchasedt.LineTotal;

                bool msg = await iv.createInvoiceAsync(invoice);

                if (msg)
                {
                    return("success");
                }
                else
                {
                    return("fail");
                }
                // return "success";
            }
            else
            {
                return("fail");
            }
        }
Beispiel #2
0
        public async Task <IActionResult> ItemEdit(int id)
        {
            ServiceReference_Item.Item i = await item.findItembyIdAsync(id);

            ServiceReference_Category.Category[] lst_categories = await cc.getAllCategoryAsync();

            ServiceReference_Supplier.Supplier[] lst_suppliers = await s.getAllSupplierAsync();

            ServiceReference_Item.Item[] lst_parentitems = await item.getAllItemAsync();

            ServiceReference_Unit.Unit[] lst_unit = await u.getAllUnitAsync();

            ItemModel im = new ItemModel()
            {
                parentitems     = lst_parentitems,
                categories      = lst_categories,
                suppliers       = lst_suppliers,
                units           = lst_unit,
                ItemId          = i.ItemId,
                ItemName        = i.ItemName,
                ImageItem       = i.ImageItem,
                MoreImage       = i.MoreImage,
                ImageUpdate     = i.MoreImage,
                DescriptionItem = i.DescriptionItem,
                MinQuantity     = i.MinQuantity,
                Price           = i.Price,
                Discount        = i.Discount,
                CategoryId      = i.CategoryId,
                SupplierId      = i.SupplierId,
                ParentItem      = i.ParentItem,
                AddedDate       = i.AddedDate,
                Warranty        = i.Warranty,
                UnitId          = i.UnitId,
                Note            = i.Note,
                ShippingFee     = i.ShippingFee,
                FAQ             = i.FAQ,
                StatusItem      = i.StatusItem
            };

            ViewBag.flag    = flag;
            ViewBag.message = message;
            flag            = "";
            message         = "";
            return(View(im));
        }
Beispiel #3
0
        public async Task <IActionResult> ItemDetail(int id, int cateId)
        {
            ServiceReference_Item.Item items = await itm.findItembyIdAsync(id);

            ServiceReference_Unit.Unit[] lstUnit = await unit.getAllUnitAsync();

            ServiceReference_Item.Item[] lstRelatedItem = await itm.findItembyCategoryIdAsync(cateId);

            ServiceReference_Feedback.Feedback[] feedbacks = await fb.findFeedbackbyItemIdAsync(id);

            List <RecentViewedItem> lst = new List <RecentViewedItem>();

            byte[] ViewItemsession;
            HttpContext.Session.TryGetValue("RecentProductList", out ViewItemsession);
            string RecentProductList;

            if (ViewItemsession != null)
            {
                RecentProductList = Encoding.UTF8.GetString(ViewItemsession);
                if (RecentProductList == "" || RecentProductList == null)
                {
                    lst = new List <RecentViewedItem>();
                }
                else
                {
                    //convert  string --> lst
                    lst = (List <RecentViewedItem>)JsonConvert.DeserializeObject <List <RecentViewedItem> >(RecentProductList);
                }
            }
            else
            {
                RecentProductList = "";
                lst = new List <RecentViewedItem>();
            }
            // Add product to recent list (make list contain max 3 items; change if you like)
            AddRecentProduct(lst, id, items.ItemName, items.ImageItem, items.Price, items.Unit.UnitName, cateId, 4);

            //luu session;
            RecentProductList = JsonConvert.SerializeObject(lst);
            ViewItemsession   = Encoding.UTF8.GetBytes(RecentProductList);
            HttpContext.Session.Set("RecentProductList", ViewItemsession);

            // Store recentProductList to ViewData keyed as "RecentProductList" to use it in a view
            ViewData["RecentProductList"] = lst;

            CategoryModel iemModel = new CategoryModel
            {
                ItemById           = items,
                listUnit           = lstUnit,
                listItemByCategory = lstRelatedItem,
                lst_feedback       = feedbacks
            };

            ViewBag.ItemId = id;
            return(View(iemModel));
        }
        public async Task <JsonResult> Get(int id)
        {
            var item = await itm.findItembyIdAsync(id);

            return(Json(item));
        }