示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        public ActionResult DeleteConfirmed(long id)
        {
            CastMaster CastMasters = db.CastMasters.Find(id);

            db.CastMasters.Remove(CastMasters);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult DeleteConfirmed(int id)
        {
            CastMaster castmaster = db.CastMasters.Find(id);

            db.CastMasters.Remove(castmaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
        //
        // GET: /CastMasterAdmin/Details/5

        public ActionResult Details(int id = 0)
        {
            CastMaster castmaster = db.CastMasters.Find(id);

            if (castmaster == null)
            {
                return(HttpNotFound());
            }
            return(View(castmaster));
        }
示例#6
0
 public ActionResult Edit(CastMaster castmaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(castmaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(castmaster));
 }
示例#7
0
        public ActionResult Create(CastMaster castmaster)
        {
            if (ModelState.IsValid)
            {
                db.CastMasters.Add(castmaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(castmaster));
        }
示例#8
0
        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));
        }
示例#9
0
        // 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));
        }
示例#10
0
        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();
 }