public ActionResult DeleteConfirmed(int id)
        {
            EstateAgentModel estateAgentModel = db.EstateAgentModels.Find(id);

            db.EstateAgentModels.Remove(estateAgentModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,CompanyName,LastName,FirstName,JoinDate")] EstateAgentModel estateAgentModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(estateAgentModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(estateAgentModel));
 }
        // GET: EstateAgentModels/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EstateAgentModel estateAgentModel = db.EstateAgentModels.Find(id);

            if (estateAgentModel == null)
            {
                return(HttpNotFound());
            }
            return(View(estateAgentModel));
        }
        public ActionResult Create([Bind(Include = "ID,CompanyName,LastName,FirstName,JoinDate")] EstateAgentModel estateAgentModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.EstateAgentModels.Add(estateAgentModel);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                ModelState.AddModelError("", "Unable to save changes.");
            }

            return(View(estateAgentModel));
        }
Exemplo n.º 5
0
 public async Task <EstateAgent> AddEstateAgent([FromBody] EstateAgentModel estateAgent)
 {
     return(await _estateAgentRepository.AddEstateAgent(estateAgent));
 }