Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            NationalitiesModel nationalitiesModel = nl.find(id);

            nl.remove(nationalitiesModel);
            return(RedirectToAction("Index"));
        }
Example #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));
        }
Example #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);
        }
Example #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));
        }
Example #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);
        }
 public ActionResult NationalityEdit(NationalitiesModel nationalitiesModel)
 {
     _serviceNationalities.Update(nationalitiesModel.ModelToEnity());
     return(RedirectToAction("NationalityEdit"));
 }
 public ActionResult NationalityInsert(NationalitiesModel nationalitiesModel)
 {
     _serviceNationalities.Insert(nationalitiesModel.ModelToEnity());
     return(RedirectToAction("NationalityList"));
 }
Example #8
0
 public void remove(NationalitiesModel nationalitiesModel)
 {
     db.Nationalities.Remove(nationalitiesModel);
     db.SaveChanges();
 }
Example #9
0
 public void edit(NationalitiesModel nationalitiesModel)
 {
     db.Entry(nationalitiesModel).State = EntityState.Modified;
     db.SaveChanges();
 }
Example #10
0
 public void create(NationalitiesModel nationalitiesModel)
 {
     db.Nationalities.Add(nationalitiesModel);
     db.SaveChanges();
 }