Exemple #1
0
        public JsonResult Add(CreateUserRequest request)
        {
            if (request.UserID <= 0)
            {
                User user = new User();
                user.UserID = request.UserID;
                user.UserKey = request.UserKey;
                user.Type = request.Type;
                user.Username = request.Username;
                user.IsPasswordChanged = 'N';
                user.Language = request.Language;

                db.Users.Add(user);
                db.SaveChanges();
            }
            else
            {
                User user = db.Users.Where(x => x.UserID == request.UserID).FirstOrDefault();
                if (user != null)
                {
                    user.Type = request.Type;
                    user.Username = request.Username;

                    db.SaveChanges();
                }

            }

            return Json("true");
        }
        public ActionResult AddUserAdmin(LandlordAdmin model)
        {

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

            CreateLandlordAdminRequest adminRequest = new CreateLandlordAdminRequest();
            adminRequest.LandlordAdminID = model.LandlordAdminID;
            adminRequest.TelWork = model.TelWork;
            adminRequest.TelMobile = model.TelMobile;
            adminRequest.Email = model.Email;
            adminRequest.FirstName = model.FirstName;
            adminRequest.LastName = model.LastName;
            adminRequest.IDNumber = model.IDNumber;
            adminRequest.UserKey = model.LandlordAdminID;


            var result = ApiWrapper.Post<LandlordAdminResponse>("api/landlordadmin/add", adminRequest);

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


            if (string.IsNullOrEmpty(Request.QueryString["returnurl"]))
                return Redirect("/user/list/a");
            else
                return Redirect(Request.QueryString["returnurl"]);
        }
        public ActionResult AddUserOwner(Owner model)
        {

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

            CreateOwnerRequest ownerRequest = new CreateOwnerRequest();
            ownerRequest.OwnerID = model.OwnerID;
            ownerRequest.Type = model.OwnerType;
            ownerRequest.Name = model.Name;
            ownerRequest.UnitNr = model.UnitNr;
            ownerRequest.ComplexName = model.ComplexName;
            ownerRequest.StreetNumber = model.StreetNumber;
            ownerRequest.StreeName = model.StreetName;
            ownerRequest.Suburb = model.Suburb;
            ownerRequest.City = model.City;
            ownerRequest.PostalCode = model.PostalCode;
            ownerRequest.TelWork = model.TelWork;
            ownerRequest.TelMobile = model.TelMobile;
            ownerRequest.Fax = model.Fax;
            ownerRequest.Email = model.Email;
            ownerRequest.Website = model.Website;
            ownerRequest.Title = model.Title;
            ownerRequest.FirstName = model.FirstName;
            ownerRequest.SecondName = model.SecondName;
            ownerRequest.ThirdName = model.ThirdName;
            ownerRequest.LastName = model.LastName;
            ownerRequest.IDNumber = model.IDNumber;


            var result = ApiWrapper.Post<OwnerResponse>("api/owner/add", ownerRequest);

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


            if (string.IsNullOrEmpty(Request.QueryString["returnurl"]))
                return Redirect("/user/list/o");
            else
                return Redirect(Request.QueryString["returnurl"]);
        }
        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"]);
        }
        public ActionResult AddUser(UserResponse model)
        {
            CreateUserRequest request = new CreateUserRequest();
            request.UserID = model.UserID;
            request.Username = model.Username;
            request.Type = model.Type;


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

            if (string.IsNullOrEmpty(Request.QueryString["returnurl"]))
                return Redirect("/");
            else
                return Redirect(Request.QueryString["returnurl"]);
        }
        public JsonResult AddedUser(UserResponse model)
        {
            CreateUserRequest request = new CreateUserRequest();
            request.UserID = model.UserID;
            request.Username = model.Username;
            request.Type = model.Type;


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

            return Json(result);
        }