public IActionResult Add() { var model = new TenantUpdateModel(); ViewBag.PaymentType = Enum.GetNames(typeof(PaymentType)); ViewBag.BillType = Enum.GetNames(typeof(PrintingFormat)); return(View(model)); }
public IActionResult Edit(TenantUpdateModel model) { if (ModelState.IsValid) { model.EditTenant(); } ViewBag.PaymentType = Enum.GetNames(typeof(PaymentType)); ViewBag.BillType = Enum.GetNames(typeof(PrintingFormat)); return(View(model)); }
public IHttpActionResult UpdateTenant(TenantUpdateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { Cad.UpdateTenant(model.UserId, model.FirstName, model.LastName, model.DateofBirth, model.Phone); } catch (ConnectedApartmentsException e) { return(BadRequest(e.Message)); } catch (Exception) { return(InternalServerError()); } return(GetResponse()); }
public UpdateTenantTests() { facade = new Mock <IFacade>(); var username = "******"; var identity = new GenericIdentity(username, ""); var nameIdentityClaim = new Claim(ClaimTypes.NameIdentifier, username); identity.AddClaim(nameIdentityClaim); var principal = new Mock <IPrincipal>(); principal.Setup(p => p.Identity).Returns(identity); principal.Setup(p => p.IsInRole("Tenant")).Returns(true); model = new TenantUpdateModel() { DateofBirth = new DateTime(1995, 03, 16), FirstName = "Vasileios", LastName = "Papadopoulos", Phone = "0123456789", UserId = "3445" }; controllerContext = new HttpControllerContext { RequestContext = { Principal = principal.Object } }; }