public async Task <IActionResult> Put(int id, [FromForm] Inquilinos inquilinos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    contexto.Inquilinos.Update(inquilinos);
                    contexto.SaveChanges();
                    return(Ok(inquilinos));
                }

                return(BadRequest());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InquilinoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Example #2
0
 public ActionResult Delete(int id, Inquilinos entidad)
 {
     try
     {
         repositorioInquilinos.Baja(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception ex)
     {
         ViewBag.Error      = ex.Message;
         ViewBag.StackTrate = ex.StackTrace;
         return(View(entidad));
     }
 }
        public async Task <IActionResult> Post([FromForm] Inquilinos inquilinos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    contexto.Inquilinos.Add(inquilinos);
                    contexto.SaveChanges();
                    return(CreatedAtAction(nameof(Get), new { id = inquilinos.IdInq }, inquilinos));
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Example #4
0
 public ActionResult Create(Inquilinos i)
 {
     try
     {
         if (ModelState.IsValid)
         {
             int res = repositorioInquilinos.Alta(i);
             return(RedirectToAction(nameof(Index)));
         }
         else
         {
             ModelState.AddModelError("", "Error de registro, verifique Datos!!!");
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Example #5
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            Inquilinos i = null;

            try
            {
                i                  = repositorioInquilinos.ObtenerPorId(id);
                i.Nombre           = collection["Nombre"];
                i.Apellido         = collection["Apellido"];
                i.Dni              = collection["Dni"];
                i.Telefono         = collection["Telefono"];
                i.DireccionTrabajo = collection["DireccionTrabajo"];
                i.Nombre_Garante   = collection["Nombre_Garante"];
                i.Dni_Garante      = collection["Dni_Garante"];
                repositorioInquilinos.Modificacion(i);
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                ViewBag.Error      = ex.Message;
                ViewBag.StackTrate = ex.StackTrace;
                return(View(i));
            }
        }