public ActionResult EntryDelete(string id) { var ebl = new EntryBusinessLayer(); ebl.RemoveEntry(id); return(RedirectToAction("Index")); }
public ActionResult Index() { if (!isCreated) { var entryBusinessLayer = new EntryBusinessLayer(); CatalogueEntries.Instance.AddRange(entryBusinessLayer.GetEntries()); ProductTypes.Instance.AddRange(entryBusinessLayer.GetTypes()); } isCreated = true; return(View()); }
public ActionResult TypeDelete(string id) { var ebl = new EntryBusinessLayer(); var removeType = ProductTypes.Instance.Find(x => x.IsThisUniqueId(id)); ebl.RemoveType(id); var entry = CatalogueEntries.Instance.Find(x => x.IsThisUniqueId(removeType.CatalogueEntryId)); ebl.UploadTypes(ProductTypes.Instance.ToList()); var entryModel = new EntryEditModel(entry); return(View("EntryDetails", entryModel)); }
public ActionResult SaveEntry([Bind(Include = "UniqueId,Name,ValidFrom, ValidTo")] EntryEditModel p) { if (!ModelState.IsValid) { return(View("CreateEntry", p)); } var adr = CatalogueEntries.Instance.Find(x => x.IsThisUniqueId(p.UniqueId)); if (adr == null) { return(HttpNotFound()); } adr.Name = p.Name; adr.Valid.From = p.ValidFrom; adr.Valid.To = p.ValidTo; var ebl = new EntryBusinessLayer(); ebl.UploadEntries(CatalogueEntries.Instance.ToList()); return(RedirectToAction("Index")); }
public ActionResult SaveType([Bind(Include = "UniqueId, Name, Description, ValidFrom, ValidTo")] ProductTypeModel p) { if (!ModelState.IsValid) { return(View("CreateType", p)); } var type = ProductTypes.Instance.Find(x => x.IsThisUniqueId(p.UniqueId)); if (type == null) { return(HttpNotFound()); } type.Name = p.Name; type.Description = p.Description; type.Valid.From = p.ValidFrom; type.Valid.To = p.ValidTo; var ebl = new EntryBusinessLayer(); ebl.UploadTypes(ProductTypes.Instance.ToList()); return(EntryDetails(type.CatalogueEntryId)); }
public ActionResult CreateEntry([Bind(Include = "UniqueId,Name,ValidFrom, ValidTo")] EntryEditModel p) { if (!ModelState.IsValid) { return(View("CreateEntry", p)); } var entry = new CatalogueEntry() { UniqueId = Guid.NewGuid().ToString(), Name = p.Name, CatalogueId = productCatalogue.UniqueId, Valid = new Period() { From = p.ValidFrom, To = p.ValidTo } }; var ebl = new EntryBusinessLayer(); ebl.SaveEntry(entry); CatalogueEntries.Instance.Add(entry); //ebl.UploadEntries(CatalogueEntries.Instance.ToList()); return(RedirectToAction("Index")); }
public ActionResult CreateType( [Bind(Include = "UniqueId,Name,Description,ValidFrom,ValidTo,CatalogueEntryId")] ProductTypeModel p) { if (!ModelState.IsValid) { return(View("CreateType", p)); } var type = new ProductType() { UniqueId = Guid.NewGuid().ToString(), Name = p.Name, Description = p.Description, CatalogueEntryId = p.CatalogueEntryId, Valid = new Period() { From = p.ValidFrom, To = p.ValidTo } }; var ebl = new EntryBusinessLayer(); ProductTypes.Instance.Add(type); ebl.UploadTypes(ProductTypes.Instance.ToList()); return(EntryDetails(type.CatalogueEntryId)); }