public ActionResult Details(ObjectId id) { var product = _ProductRepo.Get(id); if (product == null) { return(View("ProductNotExists")); } var categories = _CategoryRepo.GetByIds(product.CategoryIds); var form = new ProductDetailsForm(product, categories); return(View(form)); }
public LossForProduct GetLossForProduct(Guid productId) { Product Product = ProductRepo.Get(x => x.Id == productId); LossForProduct LossRecords = new LossForProduct(); Batch[] ProductInStoreRecords = BatchRepo.GetAll(x => x.ProductId == productId).ToArray(); Guid[] ProductInStoreIds = ProductInStoreRecords.Select(x => x.Id).ToArray(); Loss[] LossesForProduct = LossRepo.GetAll(x => x.Batch.ProductId == productId).OrderBy(x => x.DateOfLoss).ToArray(); Dictionary <int, Dictionary <Month, double> > LossPerYear = new Dictionary <int, Dictionary <Month, double> >(); LossPerYear = GroupLossPerYear(LossesForProduct); foreach (var item in LossPerYear) { int Year = item.Key; Dictionary <Month, double> LossPerMonth = item.Value; LossRecords.LossForProductInYear.Add(new LossForProductInYear() { Year = Year, LossPerMonth = LossPerMonth, }); } LossRecords.Product = Product; return(LossRecords); }
public ProfitsForProduct GetProfitForProduct(Guid productId, Expression <Func <Transaction, bool> > TransactionPredicate = null) { Product Product = ProductRepo.Get(x => x.Id == productId); ProfitsForProduct ProfitRecords = new ProfitsForProduct(); ProfitRecords.Product = Product; Transaction[] TransactionsForProduct = TransactionPredicate == null? TransactionRepo.GetAll(x => x.Batch.ProductId == productId).OrderBy(x => x.DateOfTransaction).ToArray() : TransactionRepo.GetAll(x => x.Batch.ProductId == productId).Where(TransactionPredicate).OrderBy(x => x.DateOfTransaction).ToArray(); Dictionary <int, Dictionary <Month, double> > ProfitsPerYear = new Dictionary <int, Dictionary <Month, double> >(); ProfitsPerYear = GroupProfitsPerYear(TransactionsForProduct); foreach (var item in ProfitsPerYear) { int Year = item.Key; Dictionary <Month, double> ProfitsPerMonth = item.Value; ProfitRecords.ProfitsForProductInYear.Add(new ProfitsForProductInYear() { Year = Year, ProfitsPerMonth = ProfitsPerMonth, }); } return(ProfitRecords); }
[Route("Products")] //Add Route public IActionResult Index() { ViewBag.Action = "Edit"; var Products = ProductRepo.Get(orderBy: products => products.OrderBy(g => g.Name)).ToList(); return(View(Products)); }
public TransactionsForProduct GetTransactionsForProduct(Guid productId, out Dictionary <int, Dictionary <Month, double> > TurnoverPerYear, Expression <Func <Transaction, bool> > TransactionPredicate = null) { Product Product = ProductRepo.Get(x => x.Id == productId); TransactionsForProduct TransactionsRecords = new TransactionsForProduct(); Batch[] ProductInStoreRecords = BatchRepo.GetAll(x => x.ProductId == productId).ToArray(); Guid[] ProductInStoreIds = ProductInStoreRecords.Select(x => x.Id).ToArray(); Transaction[] TransactionsForProduct = TransactionPredicate == null?TransactionRepo.GetAll(x => x.Batch.ProductId == productId).OrderBy(x => x.DateOfTransaction).ToArray() : TransactionRepo.GetAll(x => x.Batch.ProductId == productId).Where(TransactionPredicate).OrderBy(x => x.DateOfTransaction).ToArray(); Dictionary <int, Dictionary <Month, double> > TransactionsPerYear = new Dictionary <int, Dictionary <Month, double> >(); TransactionsPerYear = GroupTransactionsPerYear(TransactionsForProduct, out TurnoverPerYear); if (TransactionsPerYear != null) { foreach (var item in TransactionsPerYear) { int Year = item.Key; Dictionary <Month, double> TransactionsPerMonth = item.Value; TransactionsRecords.TransactionsForProductInYear.Add(new TransactionsForProductInYear() { Year = Year, TransactionsPerMonth = TransactionsPerMonth }); } TransactionsRecords.Product = Product; return(TransactionsRecords); } return(null); }
public ActionResult Edit(int id) { ViewBag.Product = new SelectList(ProductRepo.Get(), "Id", "Name"); ProductViewModel model = ProductRepo.GetById(id); return(View("_Edit", model)); }
//Add Item CLOSE public ActionResult CloseList(int id) { ViewBag.Product = new SelectList(ProductRepo.Get(), "Id", "Name"); ViewBag.Description = new SelectList(ProductRepo.Get(), "Id", "Description"); List <DesignItemViewModel> model = DesignRequestRepo.GetCloseItem(id); return(PartialView("_CloseList", DesignApproveRepo.Get(id))); }
public ViewResult Edit(int id) { ViewBag.Action = "Edit"; ViewBag.Products = ProductRepo.Get(orderBy: products => products.OrderBy(g => g.Name)).ToList(); var product = ProductRepo.Get(id); return(View(product)); }
public ActionResult AddItem() { ViewBag.Product = new SelectList(ProductRepo.Get(), "Id", "Name"); ViewBag.Description = new SelectList(ProductRepo.Get(), "Id", "Description"); ViewBag.Employee = new SelectList(DesignRequestRepo.GetPic(), "Id", "Full_Name"); DesignItemViewModel model = new DesignItemViewModel(); return(PartialView("_AddItem", model)); }
public ActionResult List() { UserViewModel access = DesignApproveRepo.GetIdByName(User.Identity.Name); if (access.Role == "Admin") { return(PartialView("_List", ProductRepo.Get())); } else { return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }))); } }
//GET : New Product public ActionResult Create() { ViewBag.Product = new SelectList(ProductRepo.Get(), "Id", "Name"); UserViewModel access = DesignApproveRepo.GetIdByName(User.Identity.Name); if (access.Role == "Admin") { return(PartialView("_Create", new ProductViewModel())); } else { return(new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }))); } }
private void cmbCategories_SelectedIndexChanged(object sender, EventArgs e) { List <Product> list = new List <Product>(); foreach (Product p in prepo.Get()) { if (p.CategoryID == ((Category)cmbCategories.SelectedItem).CategoryID) { list.Add(p); } } cmbProducts.DataSource = list; cmbProducts.DisplayMember = "ProductName"; }
public Dictionary <TransactionType, int> GetSalesToAuctionInformationForProduct(Guid ProductId) { Product Product = ProductRepo.Get(x => x.Id == ProductId); Transaction[] SalesTransactions = TransactionForProductByCriteria(x => x.TransactionType == TransactionType.Sale); Transaction[] AuctionTransactions = TransactionForProductByCriteria(x => x.TransactionType == TransactionType.Auction); int SalesQuantity = SalesTransactions.Sum(x => x.Quantity); int AuctionQuantity = AuctionTransactions.Sum(x => x.Quantity); return(new Dictionary <TransactionType, int>() { { TransactionType.Sale, SalesQuantity }, { TransactionType.Auction, AuctionQuantity }, }); }
public List <ProfitLossForBatch> ProfitsForProductByBatch(Guid id) { List <ProfitLossForBatch> Record = new List <ProfitLossForBatch>(); Product product = ProductRepo.Get(x => x.Id == id); product.Batches.ToList().ForEach(item => { double Value = CalculateProfitLossForBatch(item.Id); Record.Add(new ProfitLossForBatch() { Batch = item, Transactions = item.Transactions.ToList(), Value = Value, State = Value < 0 ? BatchProfitLoss.Loss : (Value > 0 ? BatchProfitLoss.Profit : BatchProfitLoss.None), }); }); return(Record); }
public IActionResult Edit(Product product) { if (ModelState.IsValid) { if (product.ProductID == 0) { ProductRepo.Insert(product); } else { ProductRepo.Update(product); } UnitOfWork.Save(); TempData["message"] = $"{product.Name} added to database"; return(RedirectToAction("Index", "Product")); } else { ViewBag.Action = (product.ProductID == 0) ? "Add" : "Edit"; ViewBag.Products = ProductRepo.Get(orderBy: products => products.OrderBy(g => g.Name)).ToList(); return(View(product)); } }
public ActionResult List() { return(PartialView("_List", ProductRepo.Get())); }
public static async void GetAllInitData() { try { CmpList = new ObservableCollection <Model.Company>(); BrandList = new ObservableCollection <Model.Brand>(); CountryofOriginList = new ObservableCollection <Model.CountryofOrigin>(); OpeningApperenceList = new ObservableCollection <Model.OpeningApperence>(); PackageConditionList = new ObservableCollection <Model.PackageCondition>(); PalletConditionList = new ObservableCollection <Model.PalletCondition>(); ProducerList = new ObservableCollection <Model.Producer>(); ProductList = new ObservableCollection <Model.Product>(); SizeTbList = new ObservableCollection <Model.SizeTb>(); VarietyList = new ObservableCollection <Model.Variety>(); InspectionHeaderList = new ObservableCollection <InspectionHeaderTable>(); InspectionDetailsList = new ObservableCollection <InspectionDetailTable>(); bool IsDatabaseUpdate = (Boolean)RememberMe.Get("isDatabaseUpdate", true); //if (ConfigurationCommon.App_Online && IsDatabaseUpdate == false) //this working is disable //{ if (ConfigurationCommon.App_Online) { UserDialogs.Instance.ShowLoading("Going for Databse Setup..."); #region for_cmp CompaniesRequestDTO companiesRequestDTO = new CompaniesRequestDTO() { IsActive = true }; var resultApplication = await webServiceManager.GetCompaniesbyAppIdAsync(companiesRequestDTO).ConfigureAwait(true); foreach (var item in resultApplication.Data.Companies) { CmpList.Add(new Model.Company { Id = item.Id, CompanyAddress = item.CompanyAddress, CompanyEmail = item.CompanyEmail, CompanyName = item.CompanyName, IsActive = item.IsActive, }); } await CmpRepo.DeleteAllAsync <InspectionApp.Model.Company>(); await CmpRepo.InsertAll(CmpList); // for cmp data saving #endregion CompanyId = Convert.ToInt32(RememberMe.Get("CmpID")); CommonRequestDTO commonRequestDTO = new CommonRequestDTO() { CompanyId = CompanyId }; var result = await webServiceManager.GetAllDatabyCmpIdAsync(commonRequestDTO).ConfigureAwait(true); if (result.IsSuccess) { if (result.Data.Brand.Count > 0) { foreach (var data in result.Data.Brand) { BrandList.Add(new Model.Brand { Id = data.Id, BrandName = data.BrandName, CompanyId = data.CompanyId, ProductID = data.ProductID, VarietyId = data.VarietyId, }); } await BranRepo.DeleteAllAsync <InspectionApp.Model.Brand>(); await BranRepo.InsertAll(BrandList); } if (result.Data.CountryofOrigin.Count > 0) { foreach (var data in result.Data.CountryofOrigin) { CountryofOriginList.Add(new Model.CountryofOrigin { Id = data.Id, CompanyId = data.CompanyId, CountryName = data.CountryName }); } await CountryOriginRepo.DeleteAllAsync <InspectionApp.Model.CountryofOrigin>(); await CountryOriginRepo.InsertAll(CountryofOriginList); } if (result.Data.OpeningApperence.Count > 0) { foreach (var data in result.Data.OpeningApperence) { OpeningApperenceList.Add(new Model.OpeningApperence { Id = data.Id, ApperenceDescription = data.ApperenceDescription, CompanyId = data.CompanyId }); } await OpeningApperenceRepo.DeleteAllAsync <Model.OpeningApperence>(); await OpeningApperenceRepo.InsertAll(OpeningApperenceList); } if (result.Data.PackageCondition.Count > 0) { foreach (var data in result.Data.PackageCondition) { PackageConditionList.Add(new Model.PackageCondition { Id = data.Id, PackageConditionName = data.PackageConditionName, CompanyId = data.CompanyId }); } await PackageConditionRepo.DeleteAllAsync <Model.PackageCondition>(); await PackageConditionRepo.InsertAll(PackageConditionList); } if (result.Data.PackageCondition.Count > 0) { foreach (var data in result.Data.PalletCondition) { PalletConditionList.Add(new Model.PalletCondition { Id = data.Id, CompanyId = data.CompanyId, PalletConditionName = data.PalletConditionName } ); await PalletRepo.DeleteAllAsync <Model.PalletCondition>(); await PalletRepo.InsertAll(PalletConditionList); } } if (result.Data.PackageCondition.Count > 0) { foreach (var data in result.Data.Producer) { ProducerList.Add(new Model.Producer { Id = data.Id, CompanyId = data.CompanyId, ProducerName = data.ProducerName }); } await ProducerRepo.DeleteAllAsync <Model.Producer>(); await ProducerRepo.InsertAll(ProducerList); } if (result.Data.PackageCondition.Count > 0) { foreach (var data in result.Data.Product) { ProductList.Add(new Model.Product { Id = data.Id, CompanyId = data.CompanyId, ProductName = data.ProductName }); } await ProductRepo.DeleteAllAsync <Model.Product>(); await ProductRepo.InsertAll(ProductList); } if (result.Data.PackageCondition.Count > 0) { foreach (var data in result.Data.SizeTb) { SizeTbList.Add(new Model.SizeTb { Id = data.Id, CompanyId = data.CompanyId, SizeDescription = data.SizeDescription }); } await SizeRepo.DeleteAllAsync <Model.SizeTb>(); await SizeRepo.InsertAll(SizeTbList); } if (result.Data.Variety.Count > 0) { foreach (var data in result.Data.Variety) { VarietyList.Add(new Model.Variety { Id = data.Id, CompanyId = data.CompanyId, ProductID = data.ProductID, VarietyName = data.VarietyName }); } await VarietyRepo.DeleteAllAsync <Model.Variety>(); await VarietyRepo.InsertAll(VarietyList); } } await SyncHeaderDetails(); RememberMe.Set("isDatabaseUpdate", true); await Xamarin.Forms.Application.Current.SavePropertiesAsync(); } else { UserDialogs.Instance.ShowLoading("Loading..."); var cmpdata = await CmpRepo.Get <Model.Company>(); if (cmpdata != null) { CmpList = cmpdata; } var Producerdata = await ProducerRepo.Get <Model.Producer>(); if (Producerdata != null) { ProducerList = Producerdata; } var Productdata = await ProductRepo.Get <Model.Product>(); if (Productdata != null) { ProductList = Productdata; } var Branddata = await BranRepo.Get <Model.Brand>(); if (Branddata != null) { BrandList = Branddata; } var CountryOrigindata = await CountryOriginRepo.Get <Model.CountryofOrigin>(); if (CountryOrigindata != null) { CountryofOriginList = CountryOrigindata; } var OpeningApperencedata = await OpeningApperenceRepo.Get <Model.OpeningApperence>(); if (OpeningApperencedata != null) { OpeningApperenceList = OpeningApperencedata; } var PackageConditiondata = await PackageConditionRepo.Get <Model.PackageCondition>(); if (PackageConditiondata != null) { PackageConditionList = PackageConditiondata; } var Palletdata = await PalletRepo.Get <Model.PalletCondition>(); if (Palletdata != null) { PalletConditionList = Palletdata; } var SizeTbdata = await SizeRepo.Get <Model.SizeTb>(); if (SizeTbdata != null) { SizeTbList = SizeTbdata; } var Varietydata = await VarietyRepo.Get <Model.Variety>(); if (Varietydata != null) { VarietyList = Varietydata; } await SyncHeaderDetails(); } UserDialogs.Instance.HideLoading(); } catch (Exception ex) { UserDialogs.Instance.HideLoading(); Console.WriteLine("Error in Master Data Sync: " + ex.Message); throw ex; } }
public ActionResult ProductDetails(int id) { var result = ProductRepo.Get(id); return(View(result)); }
public IActionResult Delete(int id) { var product = ProductRepo.Get(id); return(View(product)); }
//GET : New Product public ActionResult Create() { ViewBag.Product = new SelectList(ProductRepo.Get(), "Id", "Name"); return(View("_Create", new ProductViewModel())); }