public ActionResult Edit([Bind(Include = "CastCode,ReligionID,CastName")] CastMaster CastMasters) { //if (ModelState.IsValid) //{ // db.Entry(CastMasters).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.ReligionID = new SelectList(db.ReligionMaster, "ReligionID", "ReligionShortName", CastMasters.ReligionID); //return View(CastMasters); if (ModelState.IsValid) { bool isValid = db.CastMasters.Any(x => (x.CastCode != CastMasters.CastCode) && (x.ReligionID == CastMasters.ReligionID && x.CastName == CastMasters.CastName)); if (!isValid) { db.Entry(CastMasters).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View()); } else { ViewBag.error = "Sorry! This record is Already exist!"; ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View()); } } return(View(CastMasters)); }
public ActionResult Create([Bind(Include = "CastCode,ReligionID,CastName")] CastMaster CastMasters) { //if (ModelState.IsValid) //{ // db.CastMasters.Add(CastMasters); // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.ReligionID = new SelectList(db.ReligionMaster, "ReligionID", "ReligionShortName", CastMasters.ReligionID); //return View(CastMasters); if (ModelState.IsValid) { bool isValid = db.CastMasters.Any(x => x.ReligionID == CastMasters.ReligionID && x.CastName == CastMasters.CastName); if (!isValid) { db.CastMasters.Add(CastMasters); db.SaveChanges(); ViewBag.success = "Cast Name is Successfully created!"; ModelState.Clear(); ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View()); } else { ViewBag.error = "Sorry! Cast Name is already exist!"; ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View(CastMasters)); } } ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View(CastMasters)); }
public ActionResult DeleteConfirmed(long id) { CastMaster CastMasters = db.CastMasters.Find(id); db.CastMasters.Remove(CastMasters); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { CastMaster castmaster = db.CastMasters.Find(id); db.CastMasters.Remove(castmaster); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /CastMasterAdmin/Details/5 public ActionResult Details(int id = 0) { CastMaster castmaster = db.CastMasters.Find(id); if (castmaster == null) { return(HttpNotFound()); } return(View(castmaster)); }
public ActionResult Edit(CastMaster castmaster) { if (ModelState.IsValid) { db.Entry(castmaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(castmaster)); }
public ActionResult Create(CastMaster castmaster) { if (ModelState.IsValid) { db.CastMasters.Add(castmaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(castmaster)); }
public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CastMaster CastMasters = db.CastMasters.Find(id); if (CastMasters == null) { return(HttpNotFound()); } return(View(CastMasters)); }
// GET: CastMasters/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CastMaster CastMasters = db.CastMasters.Find(id); if (CastMasters == null) { return(HttpNotFound()); } ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View(CastMasters)); }
public bool Delete(long id) { CastMaster CastMasters = db.CastMaster.Find(id); if (CastMasters != null) { db.CastMaster.Remove(CastMasters); db.SaveChanges(); return(true); } else { return(false); } }
public int AddCast(CastMaster _master, string Otype) { DALCommon dal = new DALCommon(ConStr); return(dal.AddCast(_master, Otype)); }
public UserModel() { AddressMaster = new AddressMaster(); CastMaster = new CastMaster(); }