public ActionResult Index() { BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name); // ViewBag.Stock = db.GetStockStatusReport(user.DefaultHub.HubID,).ToList(); ViewBag.Commodity = _commodityService.GetAllParents(); ViewBag.Stock = _hubService.GetStockStatusReport(user.DefaultHub.HubID, 1).ToList(); ViewBag.CommodityID = 1; return(View()); }
//public CommodityController(ICommodityRepository commodityRepository, // ICommodityTypeRepository commodityTypeRepository) //{ // this.commodityRepository = commodityRepository; // this.commodityTypeRepository = commodityTypeRepository; //} //public ActionResult Index() //{ // ViewBag.CommodityTypes = _commodityTypeService.GetAllCommodityType(); // var parents = _commodityService.GetAllParents(); // ViewBag.ParentID = new SelectList(parents, "CommodityID", "Name", 1); // var firstOrDefault = // _commodityService.GetAllParents() == null ? null : _commodityService.GetAllParents().FirstOrDefault(); // ViewBag.SelectedCommodityID = firstOrDefault != null ? firstOrDefault.CommodityID : 1; // ViewBag.Parents = parents; // var commReturn = _commodityService.GetAllCommodity() == null ? Enumerable.Empty<Commodity>() : _commodityService.GetAllCommodity().ToList(); // return View(commReturn); //} //public ActionResult CommodityListPartial() //{ // // Default to food commodities // int commodityTypeId = 1; // if (Request["type"] != null) // { // commodityTypeId = Convert.ToInt32(Request["type"]); // } // ViewBag.ShowParentCommodity = false; // var parents = _commodityService.GetAllParents().Where(o => o.CommodityTypeID == commodityTypeId).OrderBy(o => o.Name); // var firstOrDefault = parents.FirstOrDefault(); // ViewBag.SelectedCommodityID = firstOrDefault != null ? firstOrDefault.CommodityID : 1; // ViewBag.ParentID = new SelectList(parents, "CommodityID", "Name"); // return PartialView("_CommodityPartial", parents); ////} //public ActionResult SubCommodityListPartial(int? id) //{ // if (id == null) // { // id = 1; // } // ViewBag.ShowParentCommodity = true; // ViewBag.SelectedCommodityID = id; // return PartialView("_CommodityPartial", // _commodityService.GetAllSubCommoditiesByParantId(id.Value).OrderBy(o => o.Name)); //} public ActionResult GetParentList() { var parents = from listItem in _commodityService.GetAllParents() select new Commodity { CommodityID = listItem.CommodityID, Name = listItem.Name }; return(Json(new SelectList(parents.OrderBy(o => o.Name), "CommodityID", "Name"), JsonRequestBehavior.AllowGet)); }
public ActionResult Create() { var user = _userProfileService.GetUser(User.Identity.Name); var fromStore = _hubService.GetAllStoreByUser(user); var commodities = _commodityService.GetAllParents(); var programs = _programService.GetAllProgramsForReport(); var units = _unitService.GetAllUnit(); var toStore = _hubService.GetAllStoreByUser(user); var reasons = _detailService.GetReasonByMaster(Master.Constants.REASON_FOR_INTERNAL_MOVMENT); var viewModel = new InternalMovementViewModel(fromStore, commodities, programs, units, toStore, reasons); return(View(viewModel)); }
public ActionResult CreateLoss() { var user = _userProfileService.GetUser(User.Identity.Name); var commodity = _commodityService.GetAllParents(); var stores = _hubService.GetAllStoreByUser(user); var adjustmentReasonMinus = _adjustmentReasonService.GetAllAdjustmentReason().Where(c => c.Direction == "-").ToList(); var adjustmentReasonPlus = _adjustmentReasonService.GetAllAdjustmentReason().Where(c => c.Direction == "+").ToList(); var units = _unitService.GetAllUnit().ToList(); var programs = _programService.GetAllProgramsForReport(); var viewModel = new LossesAndAdjustmentsViewModel(commodity, stores, adjustmentReasonMinus, adjustmentReasonPlus, units, programs, user, 1); return(View(viewModel)); }
public ActionResult Ledger() { ViewBag.Ledgers = _ledgerService.GetAllLedger(); ViewBag.Commodities = _commodityService.GetAllParents(); return(View()); }
public ActionResult Index(int?StoreID, int?CommodityID, string ProjectID) { ViewBag.StoreID = new SelectList(GetCurrentUserProfile().DefaultHub.Stores, "StoreID", "Name", StoreID); //var StoreI = new SelectList(GetCurrentUserProfile().DefaultHub.Stores,"StoreID","Name", StoreID); ViewBag.CommodityID = new SelectList(_commodityService.GetAllParents(), "CommodityID", "Name", CommodityID); ViewBag.ProjectID = new SelectList( _projectCodeService.GetProjectCodesForCommodity(GetCurrentUserProfile().DefaultHub.HubID, (CommodityID.HasValue) ? CommodityID.Value : 1), "ProjectCodeId", "ProjectName"); //UserProfile user =UserProfile.GetUser(User.Identity.Name); //var projectInputReceives = db.Receives.FirstOrDefault(p => p.ProjectNumber == ProjectID); //var projectInputDispatches = db.Dispatches.FirstOrDefault(p => p.ProjectNumber == ProjectID); //string projectSelected = ""; //if (projectInputReceives != null) //{ // projectSelected = projectInputReceives.ProjectNumber; //} //else if (projectInputDispatches != null) //{ // projectSelected = projectInputDispatches.ProjectNumber; //} ViewBag.BinCards = _storeService.GetBinCard(UserProfile.DefaultHub.HubID, StoreID, CommodityID, ProjectID).ToList(); //ViewBag.StoreID = new SelectList(db.Stores.Where(s => s.HubID == user.DefaultWarehouse.HubID), "StoreID", "Name"); //ViewBag.CommodityID = new SelectList(db.Commodities, "CommodityID", "Name"); //var UniqueprojectsReceives = from r in db.Receives // group r by r.ProjectNumber into b // select b; //var UniqueprojectsReceivesProjects = from Ur in UniqueprojectsReceives // where Ur.Key != null // select new Cats.Web.Hub.Models.Project() // { // Name = Ur.FirstOrDefault().ProjectNumber, // ProjectID = Ur.FirstOrDefault().ProjectNumber //Ur.FirstOrDefault().ReceiveID // }; //var UniqueprojectsDispatches = from d in db.Dispatches // group d by d.ProjectNumber into a // select a; //var UniqueprojectsDispatchesProjects = from Ud in UniqueprojectsDispatches // where Ud.Key != null // select new Cats.Web.Hub.Models.Project() // { // Name = Ud.FirstOrDefault().ProjectNumber, // ProjectID = Ud.FirstOrDefault().ProjectNumber//Ud.FirstOrDefault().DispatchID // }; //List<Cats.Web.Hub.Models.Project> Uniqueprojects = UniqueprojectsReceivesProjects.Concat(UniqueprojectsDispatchesProjects).ToList();//.Distinct(new NameComparer());//,new NameComparer()); //var perfectUniques = Uniqueprojects.Distinct(new NameComparer()); //ViewBag.ProjectID = new SelectList(perfectUniques, "ProjectID", "Name"); return(View()); }
public ActionResult CreateLoss() { List <Commodity> commodity; List <StoreViewModel> stores; List <AdjustmentReason> adjustmentReasonMinus; List <AdjustmentReason> adjustmentReasonPlus; List <Unit> units; List <ProgramViewModel> programs; UserProfile user = _userProfileService.GetUser(User.Identity.Name); commodity = _commodityService.GetAllParents(); stores = _hubService.GetAllStoreByUser(user); adjustmentReasonMinus = _adjustmentReasonService.GetAllAdjustmentReason().Where(c => c.Direction == "-").ToList(); adjustmentReasonPlus = _adjustmentReasonService.GetAllAdjustmentReason().Where(c => c.Direction == "+").ToList(); units = _unitService.GetAllUnit().ToList(); programs = _programService.GetAllProgramsForReport(); LossesAndAdjustmentsViewModel viewModel = new LossesAndAdjustmentsViewModel(commodity, stores, adjustmentReasonMinus, adjustmentReasonPlus, units, programs, user, 1); return(View(viewModel)); }
public ActionResult SelectDispatchsCommodities(string dispatchId) { var commodities = new List <DispatchDetailModel>(); if (dispatchId != null) { var user = _userProfileService.GetUser(User.Identity.Name); commodities = DispatchDetailModel.GenerateDispatchDetailModels(_dispatchService.FindById(Guid.Parse(dispatchId)).DispatchDetails); //commodities = (from c in repository.DispatchDetail.GetDispatchDetail(Guid.Parse(dispatchId)) // select new Models.DispatchDetailModel() // { // CommodityID = c.CommodityID, // CommodityName = c.Commodity.Name, // Description = c.Description, // Id = c.DispatchDetailID, // DispatchedQuantityMT = c.DispatchedQuantityInMT, // RequestedQuantityMT = c.RequestedQuantityInMT, // RequestedQuantity = c.RequestedQunatityInUnit, // DispatchedQuantity = c.DispatchedQuantityInUnit, // Unit = c.UnitID, // // DispatchID = c.DispatchID // }).ToList(); foreach (var gridCommodities in commodities) { if (user.PreferedWeightMeasurment.Equals("qn")) { gridCommodities.DispatchedQuantityMT *= 10; gridCommodities.RequestedQuantityMT *= 10; } } string str = Request["prev"]; if (GetSelectedCommodities(str) != null) { // TODO: revise this section var allCommodities = GetSelectedCommodities(Request["prev"].ToString(CultureInfo.InvariantCulture)); var count = -1; foreach (var dispatchDetailViewModelComms in allCommodities) { if (dispatchDetailViewModelComms.Id == null) { //dispatchDetailViewModelComms.Id = count--; dispatchDetailViewModelComms.DispatchDetailCounter = count--; commodities.Add(dispatchDetailViewModelComms); } // // TODO the lines below are too nice to have but we need to look into the performance issue and // policies (i.e. editing should not be allowed ) may be only for quanitities // else //replace the commodity read from the db by what's comming from the user { commodities.Remove(commodities.Find(p => p.Id == dispatchDetailViewModelComms.Id)); commodities.Add(dispatchDetailViewModelComms); } } } } else { string str = Request["prev"]; if (GetSelectedCommodities(str) != null) { commodities = GetSelectedCommodities(Request["prev"].ToString(CultureInfo.InvariantCulture)); int count = -1; foreach (var rdm in commodities) { if (rdm.Id != null) { rdm.DispatchDetailCounter = count--; } } } } ViewBag.Commodities = _commodityService.GetAllParents().Select(c => new Models.CommodityModel() { Id = c.CommodityID, Name = c.Name }).ToList(); //TODO do we really need the line below //PrepareCreate(1); return(View(new GridModel(commodities))); }
//public CommodityController(ICommodityRepository commodityRepository, // ICommodityTypeRepository commodityTypeRepository) //{ // this.commodityRepository = commodityRepository; // this.commodityTypeRepository = commodityTypeRepository; //} public ActionResult Index() { ViewBag.CommodityTypes = _commodityTypeService.GetAllCommodityType(); var parents = _commodityService.GetAllParents().OrderBy(o => o.Name); ViewBag.ParentID = new SelectList(parents, "CommodityID", "Name"); var firstOrDefault = _commodityService.GetAllParents() == null ? null : _commodityService.GetAllParents().FirstOrDefault(); ViewBag.SelectedCommodityID = firstOrDefault != null ? firstOrDefault.CommodityID : 1; ViewBag.Parents = parents; var commReturn = _commodityService.GetAllCommodity() == null?Enumerable.Empty <Commodity>() : _commodityService.GetAllCommodity().ToList(); return(View(commReturn)); }