public async Task <ActionResult> AddingTenant(TenantVM newTenant) { try { if (ModelState.IsValid) { var newtenant = new Tenant { FirstName = newTenant.FirstName, LastName = newTenant.LastName, Phone = newTenant.Phone, Created = DateTime.Now, aptID = newTenant.aptID, Username = newTenant.Username }; db.Tenant.Add(newtenant); await db.SaveChangesAsync(); return(RedirectToAction("ApartmentProfile", new { ApartmentID = newTenant.aptID, BuildingID = newTenant.BuildingID })); } } catch (Exception e) { ViewBag.Message = e.Message; } return(View()); }
public ActionResult AddingTenant(int?apartmentID, int BuildingID) { if (apartmentID != null) { var newtenant = new TenantVM(); newtenant.aptID = (int)apartmentID; newtenant.BuildingID = BuildingID; return(View(newtenant)); } return(View("page doesn't meet the required elements")); }
public async Task EditTenant(TenantVM tenant) { TenantQueue officeQueue = Mapper.Map <TenantVM, TenantQueue>(tenant, options => { options.AfterMap((src, dest) => dest.UserPerformingAction = this.UserId); options.AfterMap((src, dest) => dest.TenantId = this.TenantId); }); ProcessQueueHistory processQueueHistory = new ProcessQueueHistory() { Data = JsonConvert.SerializeObject(officeQueue), AddedById = this.UserId, TenantId = this.TenantId, Status = Data.Enums.ResultStatus.Waiting, Type = Data.Enums.ProcessType.EditTenant }; await this.queueHandler.AddToQueue(processQueueHistory); }
public async Task <IActionResult> Edit([FromBody] TenantVM tenant) { await this.TenantService.EditTenant(tenant); return(Ok()); }
public async Task <IActionResult> GetById(Guid id) { TenantVM tenant = await this.TenantService.GetTenantById(id); return(Json(tenant)); }