public JsonResult Add(CreateLandlordAdminRequest request)
        {
            LandlordAdmin landlordAdmin = null;
            if (request.LandlordAdminID <= 0)
            {
                landlordAdmin = new LandlordAdmin();
                landlordAdmin.LandlordAdminID = request.LandlordAdminID;
                landlordAdmin.FirstName = request.FirstName;
                landlordAdmin.PreferredName = request.FirstName;
                landlordAdmin.LastName = request.LastName;
                landlordAdmin.IDNumber = request.IDNumber;
                landlordAdmin.TelWork = request.TelWork;
                landlordAdmin.TelMobile = request.TelMobile;
                landlordAdmin.Email = request.Email;
                landlordAdmin.UserKey = request.LandlordAdminID;

                db.LandlordAdmins.Add(landlordAdmin);
                db.SaveChanges();



            }
            else
            {
                landlordAdmin = db.LandlordAdmins.Where(x => x.LandlordAdminID == request.LandlordAdminID).FirstOrDefault();
                if (landlordAdmin != null)
                {
                    landlordAdmin.LandlordAdminID = request.LandlordAdminID;
                    landlordAdmin.FirstName = request.FirstName;
                    landlordAdmin.PreferredName = request.FirstName;
                    landlordAdmin.LastName = request.LastName;
                    landlordAdmin.IDNumber = request.IDNumber;
                    landlordAdmin.TelWork = request.TelWork;
                    landlordAdmin.TelMobile = request.TelMobile;
                    landlordAdmin.Email = request.Email;
                    landlordAdmin.UserKey = request.LandlordAdminID;

                    db.SaveChanges();
                }

            }

            return Json(landlordAdmin);
        }
Esempio n. 2
0
        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"]);
        }