public JsonResult Add(CreateLandlordAgentRequest request)
        {
            LandlordAgent landlordAgent = null;
            if (request.LandlordAgentID <= 0)
            {
                landlordAgent = new LandlordAgent();
                landlordAgent.LandlordAgentID = request.LandlordAgentID;
                landlordAgent.FirstName = request.FirstName;
                landlordAgent.PreferredName = request.FirstName;
                landlordAgent.LastName = request.LastName;
                landlordAgent.IDNumber = request.IDNumber;
                landlordAgent.TelWork = request.TelWork;
                landlordAgent.TelMobile = request.TelMobile;
                landlordAgent.Email = request.Email;
                landlordAgent.UserKey = request.LandlordAgentID;

                db.LandlordAgents.Add(landlordAgent);
                db.SaveChanges();



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

                    db.SaveChanges();
                }

            }

            return Json(landlordAgent);
        }
Beispiel #2
0
        public ActionResult AddUserAgent(LandlordAgent model)
        {

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

            CreateLandlordAgentRequest agentRequest = new CreateLandlordAgentRequest();
            agentRequest.LandlordAgentID = model.LandlordAgentID;
            agentRequest.TelWork = model.TelWork;
            agentRequest.TelMobile = model.TelMobile;
            agentRequest.Email = model.Email;
            agentRequest.FirstName = model.FirstName;
            agentRequest.LastName = model.LastName;
            agentRequest.IDNumber = model.IDNumber;
            agentRequest.UserKey = model.LandlordAgentID;


            var result = ApiWrapper.Post<LandlordAgentResponse>("api/landlordagent/add", agentRequest);

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


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