private static List <RecipeHeaderViewModel> GetIndex() { IRecipeService recipeService = ServiceController.Get <IRecipeService> (); return (recipeService .SearchRecipeKeys() .Select(recipeId => recipeService.GetRecipeNoThrow(recipeId)) .Where(recipe => recipe != null) .OrderBy(recipe => recipe.Name) .Aggregate( new List <RecipeHeaderViewModel> (), (list, recipe) => { string key = recipe.Name.FirstOrDefault(Char.IsLetterOrDigit).ToString().ToUpper(); var vm = list.FirstOrDefault(v => v.Key == key); if (vm == null) { vm = new RecipeHeaderViewModel() { Key = key, Recipes = new List <RecipeViewModel> () }; list.Add(vm); } vm.Recipes.Add(new RecipeViewModel { FileName = recipe.Key, Recipe = Sellars.Meal.UI.Model.Recipe.FromRecipe(recipe) }); return list; }) .OrderBy(vm => vm.Key) .ToList()); }
private void Application_Startup(object sender, StartupEventArgs e) { var window = new Sellars.Meal.UI.View.MainWindow(); ServiceController.Put <IRecipeService>(new FileSystemRecipeService(AppConfig.Instance.RecipePath)); //ServiceController.Put<IRecipeService> (IndexRecipeService.CreateIndex ()); object dataContext; string [] args = Environment.GetCommandLineArgs(); //IRecipe irecipe; IRecipeService recipeService = ServiceController.Get <IRecipeService> (); SelectedIndexViewModel vm = new SelectedIndexViewModel(); //if (args.Length >= 2) //{ // irecipe = recipeService.GetRecipe (new ModelId<IRecipe> (args [1])); // Sellars.Meal.UI.Model.Recipe recipe = // irecipe as Sellars.Meal.UI.Model.Recipe // ?? Sellars.Meal.UI.Model.Recipe.FromRecipe (irecipe); // dataContext = // new Sellars.Meal.UI.ViewModel.RecipeViewModel // {Recipe = recipe}; //} //else { var recipe = new Sellars.Meal.UI.Model.Recipe(); recipe.Source = new Sellars.Meal.UI.Model.Source(); recipe.Parts.Add(new Sellars.Meal.UI.Model.RecipePart() { Name = "Recipe" }); vm = new SelectedIndexViewModel { Index = GetIndex() }; var newRecipe = new RecipeViewModel { Recipe = recipe, EditMode = true }; var newHeader = new RecipeHeaderViewModel { Key = "New", Recipes = new List <RecipeViewModel> { newRecipe } }; vm.Index.Insert(0, newHeader); vm.Recipe = newRecipe; ServiceController.Put <ISourceService> (new IndexSourceService(vm.ObservableSources)); ServiceController.Put <ITagService> (new IndexTagService(vm.ObservableTags)); ServiceController.Put <Sellars.Meal.UI.Service.IIngredientService> (new IndexIngredientService(vm.ObservableIngredients)); ServiceController.Put <IDocumentPrintingService> (new DocumentPrintingService()); dataContext = vm; } window.DataContext = dataContext; App.Current.MainWindow = window; window.ShowDialog(); }
public ActionResult _Create(int Id, DateTime?date, bool?IsProdBased) //Id ==>Sale Order Header Id { RecipeHeaderViewModel H = _RecipeHeaderService.GetRecipeHeader(Id); RecipeLineViewModel s = new RecipeLineViewModel(); s.JobOrderHeaderId = H.JobOrderHeaderId; s.StockHeaderId = (int)H.StockHeaderId; s.HeaderTestingQty = H.TestingQty; s.HeaderQty = H.Qty; ViewBag.Status = H.Status; LastValues LastValues = _RecipeLineService.GetLastValues(Id); if (LastValues != null) { if (LastValues.DyeingRatio != null) { s.DyeingRatio = LastValues.DyeingRatio; } else { s.DyeingRatio = 100; } } PrepareViewBag(s); ViewBag.LineMode = "Create"; return(PartialView("_Create", s)); }
internal static List <RecipeHeaderViewModel> CreateFilteredIndexByName(List <RecipeHeaderViewModel> index, string filter) { return (index .SelectMany(rivm => rivm.Recipes) .Where(rvm => rvm.Recipe != null && rvm.Recipe.Name != null && rvm.Recipe.Name.IndexOf(filter, StringComparison.CurrentCultureIgnoreCase) >= 0) .OrderBy(rvm => rvm.Recipe.Name) .Aggregate( new List <RecipeHeaderViewModel> (), (list, rvm) => { string key = rvm.Recipe.Name.FirstOrDefault(Char.IsLetterOrDigit).ToString().ToUpper(); var ivm = list.FirstOrDefault(v => v.Key == key); if (ivm == null) { ivm = new RecipeHeaderViewModel() { Key = key, Recipes = new List <RecipeViewModel> () }; list.Add(ivm); } ivm.Recipes.Add(rvm); return list; }) .OrderBy(ivm => ivm.Key) .ToList()); }
public ActionResult Detail(int id, string IndexType, string transactionType, int?DocLineId) { if (DocLineId.HasValue) { ViewBag.DocLineId = DocLineId; } //Saving ViewBag Data:: ViewBag.transactionType = transactionType; ViewBag.IndexStatus = IndexType; RecipeHeaderViewModel s = _RecipeHeaderService.GetRecipeHeader(id); PrepareViewBag(s.DocTypeId); if (s == null) { return(HttpNotFound()); } if (String.IsNullOrEmpty(transactionType) || transactionType == "detail") { _RecipeHeaderService.LogDetailInfo(s); } return(View("Create", s)); }
private void PrepareViewBag(RecipeLineViewModel vm) { if (vm != null) { RecipeHeaderViewModel H = _RecipeHeaderService.GetRecipeHeader(vm.JobOrderHeaderId); ViewBag.DocNo = H.DocTypeName + "-" + H.DocNo; } }
public ActionResult Wizard(int id)//Document Type Id { //ControllerAction ca = new ControllerActionService(_unitOfWork).Find(id); RecipeHeaderViewModel vm = new RecipeHeaderViewModel(); vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; vm.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; return(RedirectToAction("Index", new { id = id })); }
// GET: /JobOrderHeader/Edit/5 private ActionResult Edit(int id, string IndexType) { ViewBag.IndexStatus = IndexType; RecipeHeaderViewModel s = _RecipeHeaderService.GetRecipeHeader(id); #region DocTypeTimeLineValidation try { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if ((!TimePlanValidation && !Continue)) { return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType })); } PrepareViewBag(s.DocTypeId); if (s == null) { return(HttpNotFound()); } ViewBag.Mode = "Edit"; ViewBag.transactionType = ""; ViewBag.Name = _documentTypeService.Find(s.DocTypeId).DocumentTypeName; ViewBag.id = s.DocTypeId; if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { _RecipeHeaderService.LogDetailInfo(s); } return(View("Create", s)); }
private ActionResult _Modify(int id) { RecipeLineViewModel temp = _RecipeLineService.GetStockLine(id); RecipeHeaderViewModel H = _RecipeHeaderService.GetRecipeHeader(temp.JobOrderHeaderId); temp.HeaderTestingQty = H.TestingQty; temp.HeaderQty = H.Qty; //Getting Settings if (temp == null) { return(HttpNotFound()); } PrepareViewBag(temp); #region DocTypeTimeLineValidation try { TimePlanValidation = _validator.ValidateDocumentLine(new DocumentUniqueId { LockReason = temp.LockReason }, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXCL"] += ExceptionMsg; } #endregion if ((TimePlanValidation || Continue)) { ViewBag.LineMode = "Edit"; } return(PartialView("_Create", temp)); }
// GET: /JobOrderHeader/Create public ActionResult Create(int id)//DocumentTypeId { RecipeHeaderViewModel p = new RecipeHeaderViewModel(); p.DocDate = DateTime.Now; p.DueDate = DateTime.Now; p.CreatedDate = DateTime.Now; p.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; p.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; p.DocTypeId = id; p.ProcessId = _ProcessService.Find(ProcessConstants.Dyeing).ProcessId; p.PersonProcessId = _ProcessService.Find(ProcessConstants.Sales).ProcessId; PrepareViewBag(id); LastValues LastValues = _RecipeHeaderService.GetLastValues(p.DocTypeId); if (LastValues != null) { if (LastValues.JobWorkerId != null) { p.JobWorkerId = (int)LastValues.JobWorkerId; } if (LastValues.GodownId != null) { p.GodownId = (int)LastValues.GodownId; } if (LastValues.OrderById != null) { p.OrderById = (int)LastValues.OrderById; } if (LastValues.TestingQty != null) { p.TestingQty = LastValues.TestingQty; } } p.DueDate = DateTime.Now; p.DocNo = _documentTypeService.FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".JobOrderHeaders", p.DocTypeId, p.DocDate, p.DivisionId, p.SiteId); ViewBag.Mode = "Add"; ViewBag.Name = _documentTypeService.Find(id).DocumentTypeName; ViewBag.id = id; return(View(p)); }
internal static List <RecipeHeaderViewModel> CreateFilteredIndexByTag(List <RecipeHeaderViewModel> index, string filter) { return (index .SelectMany(rivm => rivm.Recipes) .OrderBy(rvm => rvm.Recipe.Name) .SelectMany( r => (r.Recipe.Tags == null || r.Recipe.Tags.Count == 0) ? new KeyRecipePair[] { new KeyRecipePair { Key = "Untagged", Recipe = r } } : r.Recipe.Tags.Select(t => new KeyRecipePair { Key = t.Name, Recipe = r })) .GroupBy( pair => pair.Key, StringComparer.InvariantCultureIgnoreCase) .OrderBy(group => group.Key, StringComparer.InvariantCultureIgnoreCase) .Select( group => { string key = group.Key; RecipeHeaderViewModel ivm; ivm = new RecipeHeaderViewModel() { Key = key, Recipes = new List <RecipeViewModel> () }; ivm.Recipes = group .Select(pair => pair.Recipe) .ToList(); return ivm; }) .ToList()); }
public ActionResult Post(RecipeHeaderViewModel svm) { bool BeforeSave = true; #region DocTypeTimeLineValidation try { if (svm.JobOrderHeaderId <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if (svm.MachineId == null) { TempData["CSEXC"] += "Machine is recquired."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } if (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.JobOrderHeaderId <= 0) { try { _RecipeHeaderService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Modify", "RecipeHeader", new { Id = svm.JobOrderHeaderId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _RecipeHeaderService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }