コード例 #1
0
ファイル: PickSalesController.cs プロジェクト: FH-VMS/FycnApi
        public ResultObj <List <SaleModel> > GetData(string machineId = "", string payType = "", string tradeStatus = "", string salesDate = "", string tradeNo = "", int pageIndex = 1, int pageSize = 10)
        {
            // IProduct service = new ProductService();
            //List<ProductModel> products = service.GetAllProducts();

            SaleModel saleInfo = new SaleModel();

            saleInfo.MachineId = machineId;
            saleInfo.PayType   = payType;
            saleInfo.TradeNo   = tradeNo;
            if (!string.IsNullOrEmpty(tradeStatus))
            {
                saleInfo.TradeStatus = Convert.ToInt32(tradeStatus);
            }

            if (!string.IsNullOrEmpty(salesDate))
            {
                saleInfo.SaleDateStart = salesDate.Split('^')[0];
                saleInfo.SaleDateEnd   = salesDate.Split('^')[1];
            }

            saleInfo.PageIndex = pageIndex;
            saleInfo.PageSize  = pageSize;
            var sales      = _IBase.GetAll(saleInfo);
            int totalcount = _IBase.GetCount(saleInfo);

            var pagination = new Pagination {
                PageSize = pageSize, PageIndex = pageIndex, StartIndex = 0, TotalRows = totalcount, TotalPage = 0
            };

            return(Content(sales, pagination));
        }
コード例 #2
0
        public async Task <ActionResult> Create([Bind(Include = "SaleName, StartDate, EndDate, Discount, Emblem")] SaleModel saleModel)
        {
            if (ModelState.IsValid)
            {
                if (!await(from s in db.Sales where s.SaleName.ToLower() == saleModel.SaleName.ToLower() && !(s.StartDate >= saleModel.EndDate || s.EndDate <= saleModel.StartDate) select s).AnyAsync())
                {
                    List <BrandModel> brandsOnSale   = new List <BrandModel>();
                    string[]          selectedBrands = Request.Form.GetValues("CheckedBrands") ?? new string[] { };
                    foreach (string id in selectedBrands)
                    {
                        BrandModel b = await db.Brands.FindAsync(Int32.Parse(id));

                        brandsOnSale.Add(b);
                    }
                    saleModel.BrandsOnSale = brandsOnSale;
                    db.Sales.Add(saleModel);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            await this.FillViewBag();

            return(View("Error"));
        }
コード例 #3
0
        public void Post(SaleModel sale)
        {
            SaleData data   = new SaleData();
            string   userId = User.FindFirstValue(ClaimTypes.NameIdentifier); //RequestContext.Principal.Identity.GetUserId(); // getting user Id from user who is logged in. data given to only one cashier.

            data.SaveSale(sale, userId);
        }
コード例 #4
0
        public async Task <IActionResult> Put(int id, [FromBody] SaleModel sale)
        {
            Sale oldSale = await _appContext.Sales
                           .Include(s => s.Client)
                           .Include(s => s.Contact)
                           .FirstOrDefaultAsync(s => s.Id == id);

            if (oldSale == null)
            {
                return(NotFound());
            }

            oldSale.Name = sale.Name;

            if (oldSale.Client == null && (sale.ClientName != null || sale.CityId != null))
            {
                Client newClient = new Client
                {
                    Name = sale.ClientName,
                    City = sale.CityId != null ? await _appContext.Cities.FirstOrDefaultAsync(c => c.Id == sale.CityId) : null
                };
                _appContext.Clients.Add(newClient);
                oldSale.Client = newClient;
            }
            else if (oldSale.Client != null)
            {
                oldSale.Client.Name = sale.ClientName;
                oldSale.Client.City = sale.CityId != null ? await _appContext.Cities.FirstOrDefaultAsync(c => c.Id == sale.CityId) : null;

                oldSale.Client.CityId = oldSale.Client.City?.Id;
            }

            if (oldSale.Contact == null && (sale.ContactPerson != null || sale.Saller != null))
            {
                Contact newContact = new Contact
                {
                    ContactPerson = sale.ContactPerson,
                    Saler         = sale.Saller
                };
                _appContext.Contacts.Add(newContact);
                oldSale.Contact = newContact;
            }
            else if (oldSale.Contact != null)
            {
                oldSale.Contact.ContactPerson = sale.ContactPerson;
                oldSale.Contact.Saler         = sale.Saller;
            }

            await _appContext.SaveChangesAsync();

            return(Ok(new
            {
                oldSale.Id,
                oldSale.Name,
                ClientName = oldSale.Client?.Name ?? "",
                ContactName = oldSale.Contact?.ContactPerson ?? "",
                Saller = oldSale.Contact?.Saler,
                City = new { oldSale.Client?.City?.Id, Name = oldSale.Client?.City?.Name ?? "" }
            }));
        }
コード例 #5
0
        private bool CheckOut()
        {
            bool success = false;

            //Get Misc Charges
            decimal misc = decimal.Parse(textMisc.Text);

            //Create sale object
            SaleModel sale = new SaleModel
            {
                SaleDate  = DateTime.Now,
                MiscPrice = misc,
                SaleTotal = subtotal + misc
            };

            //Add to DB, if successful add to BindingList
            try
            {
                sale.SaleId = SQLiteDataAccess.SaveSale(sale, Cart);
                Sales.Add(sale);
                success = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "FAILED TO SAVE!");
            }

            return(success);
        }
コード例 #6
0
        private void DeleteSale()
        {
            //Get relevant sale object
            SaleModel sale = (SaleModel)dataGridViewSale.CurrentRow.DataBoundItem;

            //Confirm from user
            if (ConfirmDeleteItem(sale.SaleId.ToString()) == true)
            {
                try
                {
                    SQLiteDataAccess.DeleteSale(sale.SaleId);
                    Sales.Remove(sale);

                    //Must reload the product DGV to get new quantities
                    LoadProductList();

                    //Also reload empty cart
                    CleanUpSale();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "FAILED TO DELETE!");
                }
            }
        }
コード例 #7
0
        public ActionResult ViewBonus(string id)
        {
            var cate = from a in db.Categories select a;

            ViewBag.cates = cate;
            List <SaleModel> listSale = new List <SaleModel>();
            var getAllSale            = from a in db.Sales
                                        join b in db.Product_Sales on a.sale_ID equals b.sale_ID
                                        select new
            {
                product_ID  = b.product_ID,
                sale_ID     = a.sale_ID,
                min_product = a.min_product,
                sale_price  = a.sale_price
            };

            foreach (var item in getAllSale)
            {
                SaleModel s = new SaleModel();
                s.sale_ID     = item.sale_ID;
                s.sale_price  = (int)item.sale_price;
                s.product_ID  = item.product_ID;
                s.min_product = (int)item.min_product;
                listSale.Add(s);
            }
            ViewBag.sale = listSale;
            //getName
            var c = db.Bonus.Where(i => i.bonus_ID == id).SingleOrDefault();

            ViewBag.name = c.name_bonus;
            List <ProductsModel> pro = getProductWithBonusId(id);

            ViewBag.products = pro;
            return(View());
        }
コード例 #8
0
        public void SaveSale(SaleModel saleInfo, string cashierId)
        {
            //TODO: make this solid/dry
            //start filling in models to be saved to the database
            var details  = new List <SaleDetailDBModel>();
            var products = new ProductData();
            var taxRate  = ConfigHelper.GetTaxRate() / 100;

            foreach (var item in saleInfo.SaleDetails)
            {
                var detail = new SaleDetailDBModel
                {
                    ProductId = item.ProductId,
                    Quantity  = item.Quantity,
                };

                var productInfo = products.GetProductById(item.ProductId);

                if (productInfo == null)
                {
                    throw new Exception($"The product Id of {item.ProductId} could net be found in the database");
                }

                detail.PurchasePrice = productInfo.RetailPrice * detail.Quantity;

                if (productInfo.IsTaxable)
                {
                    detail.Tax = detail.PurchasePrice * taxRate;
                }

                details.Add(detail);
            }

            //create the sale model
            var sale = new SaleDBModel()
            {
                SubTotal  = details.Sum(x => x.PurchasePrice),
                Tax       = details.Sum(x => x.Tax),
                CashierId = cashierId,
            };

            sale.Total = sale.SubTotal + sale.Tax;

            //save the sale model
            SqlDataAccess sql = new SqlDataAccess();

            sql.SaveData("dbo.spSale_Insert", sale, "RRMData");

            //get the id from the sale model
            sale.Id = sql.LoadData <int, dynamic>("spSale_Lookup", new { CashierId = sale.CashierId, SaleDate = sale.SaleDate }, "RRMData").FirstOrDefault();

            //finish filling it the sale model
            foreach (var item in details)
            {
                item.SaleId = sale.Id;

                //save the sale detail models
                sql.SaveData("dbo.spSaleDetail_Insert", item, "RRMData");
            }
        }
コード例 #9
0
        public async Task <SaleModel> UpdateSaleAsync(SaleModel sale)
        {
            var saleEntity = _mapper.Map <Sale>(sale);
            await _saleRepository.UpdateSaleAsync(saleEntity);

            return(sale);
        }
コード例 #10
0
        public void Post(SaleModel sale)
        {
            SaleData date   = new SaleData(_config);
            string   userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            date.SaveSale(sale, userId);
        }
コード例 #11
0
        public async Task <ActionResult> BrowseByID(int SaleID, int?Page)
        {
            SaleModel sale = await db.Sales.FindAsync(SaleID);

            SaleBrowseViewModel model = new SaleBrowseViewModel();

            model.AllActiveSales = await db.GetActiveSalesAsync();

            model.ThisSale = sale;

            IList <ProductModel> productsInSale = await db.GetAllProductsInSaleAsync(SaleID);

            int maxRows  = 4;
            int maxCols  = 4;
            int maxPages = decimal.ToInt32(decimal.Ceiling((decimal)productsInSale.Count / (decimal)(maxRows * maxCols)));
            IList <ProductModel> productPage = (from p in productsInSale select p).Skip((maxRows * maxCols) * ((Page ?? 1) - 1)).Take(maxRows * maxCols).ToList();

            model.ProductsPage = productPage;

            ViewBag.MaxRows  = maxRows;
            ViewBag.MaxCols  = maxCols;
            ViewBag.Page     = Page ?? 1;
            ViewBag.MaxPages = maxPages;

            await this.FillViewBag();

            return(View("Browse", model));
        }
コード例 #12
0
        public void Post(SaleModel sale)
        {
            SaleData data   = new SaleData(_config);
            string   userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // old way - RequestContext.Principal.Identity.GetUserId();

            data.SaveSale(sale, userId);
        }
コード例 #13
0
        public async Task <ActionResult> Edit(int?SaleID)
        {
            if (SaleID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SaleModel saleModel = await db.Sales.FindAsync(SaleID);

            if (saleModel == null)
            {
                return(HttpNotFound());
            }

            SaleEditViewModel viewModel = new SaleEditViewModel();

            viewModel.Discount  = saleModel.Discount;
            viewModel.Emblem    = saleModel.Emblem;
            viewModel.StartDate = saleModel.StartDate;
            viewModel.EndDate   = saleModel.EndDate;
            viewModel.SaleID    = saleModel.SaleID;
            viewModel.SaleName  = saleModel.SaleName;

            viewModel.BrandsOnSale = saleModel.BrandsOnSale.ToList();
            viewModel.AllBrands    = (await db.Brands.ToListAsync()).Except(viewModel.BrandsOnSale).ToList();

            await this.FillViewBag();

            ViewBag.DefaultIMG = Url.Content("/Content/icons/DefaultSale.png");
            return(View(viewModel));
        }
コード例 #14
0
        public async Task <ActionResult> Edit([Bind(Include = "SaleID, SaleName, StartDate, EndDate, Discount, Emblem")] SaleEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!await(from s in db.Sales where s.SaleID != model.SaleID && s.SaleName.ToLower() == model.SaleName.ToLower() && !(s.StartDate >= model.EndDate || s.EndDate <= model.StartDate) select s).AnyAsync())
                {
                    SaleModel editedModel = await db.Sales.FindAsync(model.SaleID);

                    editedModel.BrandsOnSale.Clear();

                    List <BrandModel> selectedBrands        = new List <BrandModel>();
                    string[]          selectedBrandsStrings = Request.Form.GetValues("CheckedBrands") ?? new string[] { };
                    foreach (string str in selectedBrandsStrings)
                    {
                        BrandModel brd = await db.Brands.FindAsync(Int32.Parse(str));

                        selectedBrands.Add(brd);
                    }

                    editedModel.BrandsOnSale    = selectedBrands;
                    editedModel.Discount        = model.Discount;
                    editedModel.Emblem          = model.Emblem;
                    editedModel.EndDate         = model.EndDate;
                    editedModel.StartDate       = model.StartDate;
                    editedModel.SaleName        = model.SaleName;
                    db.Entry(editedModel).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            await this.FillViewBag();

            return(View("Error"));
        }
コード例 #15
0
        public HttpResponseMessage SuspendSale(int saleNumber, int tillNumber)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,SaleController,SuspendSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
            ErrorMessage        errorMessage;
            string              userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            var suspendSale = _suspendedSaleManger.SuspendSale(tillNumber, saleNumber, userCode, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage?.MessageStyle?.Message))
            {
                return(Request.CreateResponse(errorMessage.StatusCode,
                                              new ErrorResponse
                {
                    Error = errorMessage.MessageStyle
                }));
            }

            var newSale = new SaleModel
            {
                TillNumber          = suspendSale.TillNumber,
                SaleNumber          = suspendSale.Sale_Num,
                Customer            = suspendSale.Customer.Name,
                CustomerDisplayText = suspendSale.CustomerDisplay
            };

            _performancelog.Debug($"End,SaleController,SuspendSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(Request.CreateResponse(HttpStatusCode.OK, newSale));
        }
コード例 #16
0
        public void Post(SaleModel model)
        {
            SaleData data      = new SaleData();
            string   cashierId = RequestContext.Principal.Identity.GetUserId();

            data.SaveSale(model, cashierId);
        }
コード例 #17
0
        CartItem createCart(string productId, int quantity)
        {
            var      record = db.Products.Where(item => item.product_ID == productId).FirstOrDefault();
            CartItem i      = new CartItem();

            i.productID   = productId;
            i.quantity    = quantity;
            i.productName = record.product_name;
            i.price       = (int)record.price;
            i.photo       = record.photo;
            //bonus
            List <string> listBonusName = new List <string>();
            var           getBonus      = from b in db.Bonus
                                          join p in db.Product_Bonus on b.bonus_ID equals p.bonus_ID
                                          where p.product_ID == productId
                                          select b;

            foreach (var item in getBonus)
            {
                listBonusName.Add(item.name_bonus);
            }
            i.bonus = listBonusName;
            //sale
            SaleModel s = getSaleWithProductID(productId);

            i.min_product = s.min_product;
            i.sale_price  = s.sale_price;
            return(i);
        }
コード例 #18
0
        public void Post(SaleModel sale)
        {
            string   userId = RequestContext.Principal.Identity.GetUserId();
            SaleData data   = new SaleData();

            data.SaveSale(sale, userId);
        }
コード例 #19
0
        private SaleModel InvalidInputwithIdGreaterThan12Char()
        {
            var sale = new SaleModel()
            {
                Id                = "111111111111111111",
                CustomerId        = "1234567",
                Currency          = "US",
                LocationName      = "America",
                OpeningDebit      = 12.4M,
                SaleInvoiceNumber = "12345",
                OperatorName      = "Alex",
                TimeStamp         = DateTime.Now,
                Payments          = new List <PaymentModel>()
                {
                    new PaymentModel()
                    {
                        Description   = "New Payment",
                        PaymentAmount = 12.5M,
                        PaymentDate   = DateTime.Now
                    }
                }
            };

            return(sale);
        }
コード例 #20
0
        public void SaveSale(SaleModel saleInfo, string cashierId)
        {
            //make this solid/dryC:\Users\computer\OneDrive\Desktop\Projects\RetailManager\RMDataManager.Library\DataAccess\SaleData.cs
            var saleDetails = new List <SaleDetailDBModel>();
            var taxRate     = ConfigHelper.GetTaxRate() / 100;

            foreach (var item in saleInfo.SaleDetails)
            {
                var detail = new SaleDetailDBModel
                {
                    ProductId = item.ProductId,
                    Quantity  = item.Quantity
                };

                var productInfo = productData.GetProductById(item.ProductId);

                if (productInfo is null)
                {
                    throw new ArgumentNullException($"The Product id of { detail.ProductId } could not be found in the database");
                }
                detail.PurchasePrice = (productInfo.RetailPrice * detail.Quantity);

                if (productInfo.IsTaxable)
                {
                    detail.Tax = (detail.PurchasePrice * taxRate);
                }

                saleDetails.Add(detail);
            }

            var sale = new SaleDbModel
            {
                CashierId = cashierId,
                SubTotal  = saleDetails.Sum(x => x.PurchasePrice),
                Tax       = saleDetails.Sum(x => x.Tax),
            };

            sale.Total = sale.SubTotal + sale.Tax;

            try
            {
                sql.StartTransaction("RMData");
                //sale mode
                sql.SaveDataInTransaction("dbo.spSaleAdd", sale);
                sale.Id = sql.LoadDataInTransaction <int, dynamic>("dbo.spSaleSelect", new { sale.CashierId, sale.SaleDate })
                          .FirstOrDefault();
                foreach (var item in saleDetails)
                {
                    item.SaleId = sale.Id;
                    //sale details
                    sql.SaveDataInTransaction("dbo.spSaleDetailAdd", item);
                }
                sql.CommitTransaction();
            }
            catch
            {
                sql.RollbackTransaction();
                throw;
            }
        }
コード例 #21
0
        public void Post([FromBody] SaleModel sale)
        {
            var saleData = new SaleDataAccess();
            var id       = RequestContext.Principal.Identity.GetUserId();

            saleData.SaveSale(sale, id);
        }
コード例 #22
0
        public void Post(SaleModel item)
        {
            SaleData data   = new SaleData(config);
            string   userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            data.SaveSale(item, userId);
        }
コード例 #23
0
ファイル: MachineService.cs プロジェクト: FH-VMS/FycnApi
        // 根据订单号更新出货结果
        public int PutPayResultByOrderNo(string tradeNo, bool result)
        {
            try
            {
                var conditions = new List <Condition>();

                conditions.Add(new Condition
                {
                    LeftBrace    = " AND ",
                    ParamName    = "TradeNo",
                    DbColumnName = "trade_no",
                    ParamValue   = tradeNo,
                    Operation    = ConditionOperate.Equal,
                    RightBrace   = "",
                    Logic        = ""
                });
                List <SaleModel> lstSaleModel = GenerateDal.LoadByConditions <SaleModel>(CommonSqlKey.GetSalesByNo, conditions);
                if (lstSaleModel.Count == 0)
                {
                    return(2);
                }
                GenerateDal.BeginTransaction();

                SaleModel saleModel = lstSaleModel[0];
                if (saleModel != null && saleModel.TradeStatus == 1)
                {
                    //SaleModel saleInfo = new SaleModel();
                    saleModel.SalesDate         = DateTime.Now;
                    saleModel.RealitySaleNumber = 1;
                    if (result)
                    {
                        saleModel.TradeStatus = 2;
                    }
                    else
                    {
                        saleModel.RealitySaleNumber = 0;
                        saleModel.TradeStatus       = 5;
                        UpdateAddCurrStock(saleModel.MachineId, saleModel.GoodsId, 1);
                    }
                    GenerateDal.Update(CommonSqlKey.UpdatePayResult, saleModel);
                }
                GenerateDal.CommitTransaction();
                RefundService refund = new RefundService();
                if (saleModel.PayInterface == "微信")
                {
                    refund.PostRefundW(lstSaleModel);
                }
                else if (saleModel.PayInterface == "支付宝")
                {
                    refund.PostRefundA(lstSaleModel);
                }
            }
            catch (Exception e)
            {
                return(0);
            }

            return(1);
        }
コード例 #24
0
ファイル: SaleData.cs プロジェクト: ash2005/DKRetailManager
        public void SaveSale(SaleModel saleInfo, string cashierId)
        {
            //Start filling in the sale detail models we will save to the database
            List <SaleDetailDBModel> details = new List <SaleDetailDBModel>();
            ProductData products             = new ProductData();
            var         taxRate = ConfigHelper.GetTaxRate() / 100;

            foreach (var item in saleInfo.SaleDetails)
            {
                var detail = new SaleDetailDBModel
                {
                    ProductId = item.ProductId,
                    Quantity  = item.Quantity
                };

                //Get the info about this product
                var productInfo = products.GetProductById(detail.ProductId);

                if (productInfo == null)
                {
                    throw new Exception($"The product Id of {detail.ProductId} could not be found in the database");
                }

                detail.PurchasePrice = (productInfo.RetailPrice * detail.Quantity);

                if (productInfo.IsTaxable)
                {
                    detail.Tax = (detail.PurchasePrice * taxRate);
                }

                details.Add(detail);
            }

            //Create the Sale model
            SaleDBModel sale = new SaleDBModel
            {
                SubTotal  = details.Sum(x => x.PurchasePrice),
                Tax       = details.Sum(x => x.Tax),
                CashierId = cashierId
            };

            sale.Total = sale.SubTotal + sale.Tax;

            //Save the sale model
            SqlDataAccess sql = new SqlDataAccess();

            sql.SaveData <SaleDBModel>("dbo.spSale_Insert", sale, "TRMData");

            //Get the ID from the sale model
            sale.Id = sql.LoadData <int, dynamic>("spSale_Lookup", new { sale.CashierId, sale.SaleDate }, "TRMData").FirstOrDefault();

            //Finish filling in the sale detail models
            foreach (var item in details)
            {
                item.SaleId = sale.Id;
                //Save the sale detail models
                sql.SaveData("dbo.spSaleDetail_Insert", item, "TRMData");
            }
        }
コード例 #25
0
        public void SaveSale(SaleModel saleInfo, string cashierId)
        {
            List <SaleDetailDBModel> details = new List <SaleDetailDBModel>();
            var taxRate = ConfigHelper.GetTaxRate() / 100;

            foreach (var item in saleInfo.SaleDetails)
            {
                var detail = new SaleDetailDBModel
                {
                    ProductId = item.ProductId,
                    Quantity  = item.Quantity
                };

                var productInfo = _productData.GetProductById(detail.ProductId);
                if (productInfo == null)
                {
                    throw new Exception($"The product Id of {detail.ProductId} could not be found in the database.");
                }

                detail.PurchasePrice = productInfo.RetailPrice * detail.Quantity;

                if (productInfo.IsTaxable)
                {
                    detail.Tax = detail.PurchasePrice * taxRate;
                }

                details.Add(detail);
            }

            SaleDBModel sale = new SaleDBModel
            {
                SubTotal  = details.Sum(x => x.PurchasePrice),
                Tax       = details.Sum(x => x.Tax),
                CashierId = cashierId
            };

            sale.Total = sale.SubTotal + sale.Tax;
            try
            {
                _sql.StartTransaction("KRMData");

                _sql.SaveDataInTransaction("dbo.spSale_Insert", sale);

                sale.Id = _sql.LoadDataInTransaction <int, dynamic>("dbo.spSale_Lookup", new { sale.CashierId, sale.SaleDate }).FirstOrDefault();

                details.ForEach(item =>
                {
                    item.SaleId = sale.Id;
                    _sql.SaveDataInTransaction("dbo.spSaleDetail_Insert", item);
                });

                _sql.CommitTransaction();
            }
            catch
            {
                _sql.RollbackTransaction();
                throw;
            }
        }
コード例 #26
0
        public ActionResult DeleteConfirmed(int id)
        {
            SaleModel saleModel = db.SaleModels.Find(id);

            db.SaleModels.Remove(saleModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #27
0
        public int CalculateSalePrice(SaleModel Sale)
        {
            float Originalprice = Sale.price;
            float SalePercent   = (float)Sale.sale / 100;
            float SalePrice     = Originalprice * (1 - SalePercent);

            return((int)SalePrice);
        }
コード例 #28
0
        public void Post(SaleModel sale)
        {
            SaleData data = new SaleData();
            //string userId = RequestContext.Principal.Identity.GetUserId();
            string userId = "7962aed8-bfaf-41d6-bf73-bfbb4f81647c"; // TODO: 这里出问题了:register 用户是把info存入了"EFData" 这个db, 但是我们在这里query是query "KelvinData" DB.

            data.SaveSale(sale, userId);
        }
コード例 #29
0
        public void Post(SaleModel sale)
        {
            SaleData data = new SaleData();
            List <SaleDetailDBModel> details = new List <SaleDetailDBModel>();
            string userId = RequestContext.Principal.Identity.GetUserId();

            data.SaveSale(sale, userId, details);
        }
コード例 #30
0
        public async Task <SaleModel> CreateSaleAsync(SaleModel sale)
        {
            var saleEntity = _mapper.Map <Sale>(sale);
            var result     = await _saleRepository.CreateSaleAsync(saleEntity);

            sale = _mapper.Map <SaleModel>(result);
            return(sale);
        }
コード例 #31
0
        public void AddSale(API.Domain.Sale sale, string transactionId)
        {
            System.IO.Directory.CreateDirectory(this.Path);

            var path = String.Format("{0}\\{1}", this.Path, Guid.NewGuid());

            sale.Redeem.Points = 0; // no redeem if offline

            var saleModel = new SaleModel()
            {
                TransactionId = transactionId,
                Sale = sale,
                Date = DateTime.Now
            };

            string obj = JsonConvert.SerializeObject(saleModel);

            File.WriteAllText(path, obj);
        }