Example #1
0
        public JsonResult Add(CreateTenantRequest request)
        {
            Tenant tenant = null;
            if (request.TenantID <= 0)
            {
                tenant = new Tenant();
                tenant.TenantID = request.TenantID;
                tenant.Email = request.Email;
                tenant.FirstName = request.FirstName;
                tenant.IDNumber = request.IDNumber;
                tenant.LastName = request.LastName;
                tenant.PreferredName = request.PreferredName;
                tenant.SecondName = request.SecondName;
                tenant.TelMobile = request.TelMobile;
                tenant.TelWork = request.TelWork;
                tenant.ThirdName = request.ThirdName;
                tenant.Title = request.Title;
                tenant.Website = request.Website;

                db.Tenants.Add(tenant);
                db.SaveChanges();



            }
            else
            {
                tenant = db.Tenants.Where(x => x.TenantID == request.TenantID).FirstOrDefault();
                if (tenant != null)
                {
                    tenant.TenantID = request.TenantID;
                    tenant.Email = request.Email;
                    tenant.FirstName = request.FirstName;
                    tenant.IDNumber = request.IDNumber;
                    tenant.LastName = request.LastName;
                    tenant.PreferredName = request.PreferredName;
                    tenant.SecondName = request.SecondName;
                    tenant.TelMobile = request.TelMobile;
                    tenant.TelWork = request.TelWork;
                    tenant.ThirdName = request.ThirdName;
                    tenant.Title = request.Title;
                    tenant.Website = request.Website;

                    db.SaveChanges();
                }

            }

            return Json(tenant);
        }
Example #2
0
        public ActionResult AddUserTenant(Tenant model)
        {

            CreateUserRequest request = new CreateUserRequest();
            request.UserID = model.UserID;
            request.Username = model.Username;
            request.Type = model.Type;

            CreateTenantRequest tenantRequest = new CreateTenantRequest();
            tenantRequest.TenantID = model.TenantID;
            tenantRequest.Title = model.Title;
            tenantRequest.FirstName = model.FirstName;
            tenantRequest.SecondName = model.SecondName;
            tenantRequest.ThirdName = model.ThirdName;
            tenantRequest.PreferredName = model.PreferredName;
            tenantRequest.LastName = model.LastName;
            tenantRequest.IDNumber = model.IDNumber;
            tenantRequest.TelWork = model.TelWork;
            tenantRequest.TelMobile = model.TelMobile;
            tenantRequest.Email = model.Email;
            tenantRequest.Website = model.Website;


            var result = ApiWrapper.Post<TenantResponse>("api/tenant/add", tenantRequest);

            request.UserKey = result.TenantID;
            var resultUser = ApiWrapper.Post<bool>("api/user/add", request);


            if (string.IsNullOrEmpty(Request.QueryString["returnurl"]))
                return Redirect("/user/list/t");
            else
                return Redirect(Request.QueryString["returnurl"]);
        }