// GET: /Transaction/CreateIn public ActionResult CreateIn() { // set default values var transaction = new Transaction { BottleTypeId = 3, Year = DateTime.Now.Year - 1, Date = DateTime.Now.Date, Quantity = 1 }; // ViewBag.BusinessId = new SelectList(Db.Businesses, "Id", "Name"); // ViewBag.WineId = new SelectList(Db.Wines, "Id", "Name"); ViewBag.PriceInt = Math.Floor(transaction.Price); var priceCents = ("0" + (transaction.Price - Math.Floor(transaction.Price) * 100).ToString( CultureInfo.InvariantCulture)); ViewBag.PriceCents = priceCents.Substring(priceCents.Length - 2); this.PopulateBottleTypeList(); this.PopulateTransactionTypesList(true); this.PopulateYearList(); return View(transaction); }
// GET: /Transaction/CreateOut public ActionResult CreateOut() { // set default values var transaction = new Transaction { BottleTypeId = 3, Year = DateTime.Now.Year - 1, Date = DateTime.Now.Date, Quantity = 1 }; // ViewBag.BusinessId = new SelectList(Db.Businesses, "Id", "Name"); // ViewBag.WineId = new SelectList(Db.Wines, "Id", "Name"); this.PopulateBottleTypeList(); this.PopulateTransactionTypesList(false); this.PopulateYearList(); return View(transaction); }
public PartialViewResult AddTransactionIn() { var transaction = new Transaction { BottleTypeId = 3, Year = DateTime.Now.Year - 1, Date = DateTime.Now.Date, Quantity = 1 }; ViewBag.PriceInt = Math.Floor(transaction.Price); var priceCents = ("0" + (transaction.Price - Math.Floor(transaction.Price) * 100).ToString( CultureInfo.InvariantCulture)); ViewBag.PriceCents = priceCents.Substring(priceCents.Length - 2); this.PopulateBottleTypeList(); this.PopulateTransactionTypesList(true); this.PopulateYearList(); return this.PartialView("Cellar/_AddTransactionIn", transaction); }
private static CellarWineViewModel Map(CellarWineViewModel wine, Transaction transaction) { wine.WineId = transaction.WineId; wine.WineName = transaction.Wine.Name; wine.Country = transaction.Wine.Country.Name; wine.CountryId = transaction.Wine.CountryId; wine.Region = transaction.Wine.Region.Name; wine.RegionId = transaction.Wine.RegionId; wine.Stock = transaction.Quantity * transaction.TransactionType.Multiplier; wine.Qualification = transaction.Wine.Qualification.Name; wine.QualificationId = transaction.Wine.QualificationId; wine.ProducerName = transaction.Wine.Business.Name; wine.ProducerId = transaction.Wine.BusinessId; wine.ProducerCity = transaction.Wine.Business.City; wine.ProducerCountryId = transaction.Wine.Business.CountryId; wine.ProducerCountry = transaction.Wine.Business.Country.Name; wine.Year = transaction.Year; wine.Alcohol = transaction.Alcohol; wine.TotalPrice = transaction.Quantity * transaction.Price; return wine; }
private static CellarTransactionViewModel Map(CellarTransactionViewModel cellarTransaction, Transaction transaction) { cellarTransaction.WineId = transaction.WineId; cellarTransaction.WineName = transaction.Wine.Name; cellarTransaction.Country = transaction.Wine.Country.Name; cellarTransaction.CountryId = transaction.Wine.CountryId; cellarTransaction.Region = transaction.Wine.Region.Name; cellarTransaction.RegionId = transaction.Wine.RegionId; cellarTransaction.Qualification = transaction.Wine.Qualification.Name; cellarTransaction.QualificationId = transaction.Wine.QualificationId; cellarTransaction.ProducerName = transaction.Wine.Business.Name; cellarTransaction.ProducerId = transaction.Wine.BusinessId; cellarTransaction.ProducerCity = transaction.Wine.Business.City; cellarTransaction.ProducerCountryId = transaction.Wine.Business.CountryId; cellarTransaction.ProducerCountry = transaction.Wine.Business.Country.Name; cellarTransaction.Year = transaction.Year; cellarTransaction.Alcohol = transaction.Alcohol; cellarTransaction.BottleTypeId = transaction.BottleTypeId; cellarTransaction.BottleTypeName = transaction.BottleType.Name; cellarTransaction.DistributorId = transaction.BusinessId; cellarTransaction.DistributorName = transaction.Business.Name; if (transaction.Business.City != null) { cellarTransaction.DistributorCity = transaction.Business.City; } if (transaction.Business.Country != null) { cellarTransaction.DistributorCountry = transaction.Business.Country.Name; cellarTransaction.DistributorCountryId = transaction.Business.CountryId; } cellarTransaction.Date = transaction.Date.Date; cellarTransaction.TransactionId = transaction.Id; cellarTransaction.TransactionTypeId = transaction.TransactionTypeId; cellarTransaction.TransactionTypeName = transaction.TransactionType.Name; cellarTransaction.Quantity = transaction.Quantity; cellarTransaction.Price = transaction.Price; cellarTransaction.TotalPrice = transaction.Quantity * transaction.Price; cellarTransaction.Multiplier = transaction.TransactionType.Multiplier; return cellarTransaction; }
public PartialViewResult TransactionDetails(int transactionId) { var transaction = Service.GetTransactionById(transactionId); // check if this transaction belongs to this user var userId = this.GetUserId(); if (transaction.UserId != userId) { transaction = new Transaction(); } return this.PartialView("Cellar/_TransactionDetails", transaction); }