public ActionResult DeleteConfirmed(int id)
        {
            S_Country s_Country = db.S_Countries.Find(id);

            db.S_Countries.Remove(s_Country);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "CountryID,CountryName")] S_Country s_Country)
 {
     if (ModelState.IsValid)
     {
         db.Entry(s_Country).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(s_Country));
 }
        // GET: Country/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            S_Country s_Country = db.S_Countries.Find(id);

            if (s_Country == null)
            {
                return(HttpNotFound());
            }
            return(View(s_Country));
        }
示例#4
0
 public ActionResult NewList(M_List model)
 {
     if (ModelState.IsValid)
     {
         string        UsersID   = GetUser();
         List <string> ListNames = new List <string>();
         string        success   = null;
         if (model != null)
         {
             try
             {
                 success = model.SaveList(UsersID);
                 if (success != "Saved")
                 {
                     ModelState.AddModelError("Errorlistname", success);
                     ViewBag.country = new SelectList(S_Country.GetCountries(), "CountryId", "CountryName");
                     return(View());
                 }
             }
             catch (M_CustomException ex)
             {
                 if (ex.ErrorCode == 100)
                 {
                     ModelState.AddModelError("error", ex.message);
                     return(RedirectToAction("NewList"));
                 }
                 else if (ex.ErrorCode == 101)
                 {
                     ModelState.AddModelError("Error", "logical exception");
                     return(RedirectToAction("NewList"));
                 }
             }
             catch (Exception)
             {
                 ModelState.AddModelError("error", "Errr occured in business logic");
                 return(RedirectToAction("NewList"));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Create([Bind(Include = "CountryID,CountryName")] S_Country s_Country)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //db.S_Countries.Add(s_Country);
                    //db.SaveChanges();
                    S_Country.SaveCountry(s_Country);
                    return(RedirectToAction("Index"));
                }
                catch (M_CustomException ex)
                {
                }
            }

            return(View(s_Country));
        }
示例#6
0
        public ActionResult EditList(int?id)
        {
            ViewBag.country = new SelectList(S_Country.GetCountries(), "CountryId", "CountryName");
            M_List model = new M_List();

            try
            {
                model = model.EditList(id);
            }
            catch (M_CustomException ex)
            {
                if (ex.ErrorCode == 100)
                {
                    ModelState.AddModelError("error", ex.message);
                    return(RedirectToAction("EditList"));
                }
                else if (ex.ErrorCode == 101)
                {
                    ModelState.AddModelError("Error", "logical exception");
                    return(RedirectToAction("EditList"));
                }
            }
            return(View(model));
        }
示例#7
0
 public ActionResult NewList()
 {
     ViewBag.country = new SelectList(S_Country.GetCountries(), "CountryId", "CountryName");
     return(View());
 }
 // GET: Country
 public ActionResult Index()
 {
     return(View(S_Country.GetCountries()));
 }