예제 #1
0
        public ActionResult Create()
        {
            TenantCreateViewModel model = new TenantCreateViewModel();

            model.Buildings    = (from row in context.Buildings select row).ToList();
            model.BuildingList = new SelectList(model.Buildings, "ID", "Name");
            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> PostTenantCreate([FromBody] TenantCreateViewModel model)
        {
            var tenantDto = new TenantDto
            {
                Name           = model.Name,
                ParentTenantId = model.ParentId
            };
            var model2 = await _tenantService.CreateTenant(tenantDto);

            return(new JsonResult(model));
        }
예제 #3
0
        public ActionResult Create(TenantCreateViewModel model)
        {
            string userid = User.Identity.GetUserId();
            Tenant tenant = model.Tenant;

            tenant.UserId       = userid;
            tenant.User         = (from row in context.Users where row.Id == userid select row).First();
            tenant.Building     = (from row in context.Buildings where row.ID == tenant.BuildingId select row).First();
            tenant.EmailAdrress = tenant.User.Email;
            context.Tenants.Add(tenant);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public async Task <IActionResult> GetTenantCreate()
        {
            var tenantCreate = new TenantCreateViewModel();
            var result       = await _tenantService.GetTenantList();

            tenantCreate.TenantList = result.Select(c => new TenantViewModel
            {
                Id   = c.Id,
                Name = c.Name
            }).ToList();

            return(new JsonResult(tenantCreate));
        }