コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            NationalitiesModel nationalitiesModel = nl.find(id);

            nl.remove(nationalitiesModel);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        // GET: Nationalities/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NationalitiesModel nationalitiesModel = nl.find(id);

            if (nationalitiesModel == null)
            {
                return(HttpNotFound());
            }
            return(View(nationalitiesModel));
        }
コード例 #3
0
        public static Nationalities ModelToEnity(this NationalitiesModel model, bool virtualActive = false)
        {
            Nationalities entity = new Nationalities()
            {
                CountryName = model.CountryName,
                Name        = model.Name,
                Id          = model.Id
            };

            if (virtualActive)
            {
                entity.Customers = model.Customers;
            }
            return(entity);
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "nationalityID, nationalityName")] NationalitiesModel nationalitiesModel)
        {
            if (ModelState.IsValid)
            {
                if ((nl.db.Nationalities.Any(ac => ac.nationalityName.Equals(nationalitiesModel.nationalityName))))
                {
                    //TODO E.g. ModelState.AddModelError

                    return(RedirectToAction("Create"));
                }
                nl.create(nationalitiesModel);
                return(RedirectToAction("Index"));
            }

            return(View(nationalitiesModel));
        }
コード例 #5
0
        public static NationalitiesModel EntityToModel(this Nationalities entity, bool virtualActive = false)
        {
            NationalitiesModel model = new NationalitiesModel()
            {
                CountryName = entity.CountryName,
                Name        = entity.Name,
                Id          = entity.Id
            };

            if (virtualActive)
            {
                model.Customers = entity.Customers;
            }

            return(model);
        }
コード例 #6
0
 public ActionResult NationalityEdit(NationalitiesModel nationalitiesModel)
 {
     _serviceNationalities.Update(nationalitiesModel.ModelToEnity());
     return(RedirectToAction("NationalityEdit"));
 }
コード例 #7
0
 public ActionResult NationalityInsert(NationalitiesModel nationalitiesModel)
 {
     _serviceNationalities.Insert(nationalitiesModel.ModelToEnity());
     return(RedirectToAction("NationalityList"));
 }
コード例 #8
0
 public void remove(NationalitiesModel nationalitiesModel)
 {
     db.Nationalities.Remove(nationalitiesModel);
     db.SaveChanges();
 }
コード例 #9
0
 public void edit(NationalitiesModel nationalitiesModel)
 {
     db.Entry(nationalitiesModel).State = EntityState.Modified;
     db.SaveChanges();
 }
コード例 #10
0
 public void create(NationalitiesModel nationalitiesModel)
 {
     db.Nationalities.Add(nationalitiesModel);
     db.SaveChanges();
 }