public bool IsUnique(TypeApp type) { try { TypeApp tp = context.TypeApps.FirstOrDefault(t => t.Name == type.Name); if (tp != null) { return(false); } return(true); } catch { return(false); } }
public ActionResult Remove(int id) { try { if (Session["ModId"] != null) { TypeAppDAO dao = new TypeAppDAO(); TypeApp t = dao.SearchById(id); dao.Remove(t); return(RedirectToAction("Index")); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Validate(TypeApp typeapp) { try { if (ModelState.IsValid) { TypeAppDAO dao = new TypeAppDAO(); if (dao.IsUnique(typeapp)) { dao.Add(typeapp); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); } ViewBag.Lang = typeapp; return(View("Register")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditConfirm(TypeApp TypeApp) { try { if (Session["ModId"] != null) { TypeAppDAO dao = new TypeAppDAO(); TypeApp t = dao.SearchById(TypeApp.Id); t.Name = TypeApp.Name; dao.Update(); return(RedirectToAction("Index")); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("Index", "Home")); } }
private object GetTypeList() { try { TypeApp typeApp = new TypeApp(); var data = typeApp.GetList(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); foreach (TypeEntity item in data) { var fieldItem = new { encode = item.ID, fullname = item.TypeName }; dictionary.Add(item.ID.ToString(), fieldItem); } return(dictionary); } catch (Exception ex) { throw; } }
public void Remove(TypeApp type) { context.TypeApps.Remove(type); Update(); }
public void Add(TypeApp type) { context.TypeApps.Add(type); Update(); }