public async Task <ActionResult> Edit([Bind(Include = "LookupValueId,ParentId,Name,Code,Description,LogoUrl,IsDefault,IsActive,IsSystemValue")] LookUpValue lookUpValue) { if (ModelState.IsValid) { //var userId = await _api.Post("/api/User/GetUserId", new { Email = User.Identity.Name }); //lookUpValue.LastUpdatedBy = Convert.ToInt32(userId); _db.Entry(lookUpValue).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index", new { parentId = lookUpValue.ParentId })); } return(View(lookUpValue)); }
// GET: LookUpValue/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LookUpValue lookUpValue = _db.LookUpValues.Find(id); if (lookUpValue == null) { return(HttpNotFound()); } return(View(lookUpValue)); }
public async Task <ActionResult> Create([Bind(Include = "LookupValueId,ParentId,Name,Code,Description,LogoUrl")] LookUpValue lookUpValue) { if (ModelState.IsValid) { //var userId = await _api.Post("/api/User/GetUserId", new { Email = User.Identity.Name }); lookUpValue.IsActive = true; //lookUpValue.CreatedBy = Convert.ToInt32(userId); _db.LookUpValues.Add(lookUpValue); _db.SaveChanges(); return(RedirectToAction("Index", new { parentId = lookUpValue.ParentId })); } return(View(lookUpValue)); }
public ActionResult DeleteConfirmed(int id) { if (_db.LookUpValues.Any(x => x.ParentId == id)) { LookUpValue lookUpValue = _db.LookUpValues.Find(id); ViewBag.ErrorMessage = "This is a parent item for other items. Can not be deleted"; return(View(lookUpValue)); } else { LookUpValue lookUpValue = _db.LookUpValues.Find(id); _db.LookUpValues.Remove(lookUpValue); _db.SaveChanges(); return(RedirectToAction("Index")); } }
static string GetDescription(StaticListLookUpSettings lookupSettings, string value) { LookUpValue lookup = lookupSettings.LookUpValues.FirstOrDefault(x => (string)x.Value == value); return(lookup != null ? lookup.Description : ""); }