Beispiel #1
0
        public AgentProfileViewModel GetAgentProfile()
        {
            var agentProfile = new AgentProfileViewModel();

            agentProfile = new AgentProfileViewModel()
            {
                AgentLastname            = "Melissa Crosby",
                AboutAgent               = AboutAgent(),
                AgentObjectives          = GetAgentObjective(),
                AgentProfPictPath        = "img/agents/agent5.png",
                Brokerage                = "Berkshire Hathaway HomeServices Elite Real Estate",
                Specialties              = "Property Management, Buyer’s Agent, Listing Agent…",
                LicenseNumbers           = "#5452129",
                Ratings                  = "4.5",
                ReviewCount              = "16",
                LocalknowledgeRatings    = "4.5",
                ProcessexpertiseRatings  = "4.2",
                ResponsivenessRatings    = "5.0",
                NegotiationskillsRatings = "4.1"
            };

            var ratings = decimal.Parse(agentProfile.Ratings, CultureInfo.InvariantCulture.NumberFormat);

            agentProfile.IntRatings = Convert.ToInt32(Math.Truncate(ratings));
            agentProfile.IsDecimal  = true;
            return(agentProfile);
        }
Beispiel #2
0
        public async Task <IHttpActionResult> AgentChangeInfo(AgentProfileViewModel viewProfile)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var userName = User.Identity.GetUserName();
                var u        = await GetApplicationUser(userName);

                ;
                if (u == null)
                {
                    ModelState.AddModelError("", "You Need To Login");
                    return(BadRequest(ModelState));
                }

                var result = await _repo.UpdateAgent(
                    u.Id,
                    viewProfile.FullName,
                    viewProfile.Email,
                    viewProfile.Color,
                    viewProfile.CompanyName,
                    viewProfile.Model,
                    viewProfile.PlateNumber,
                    viewProfile.Type,
                    viewProfile.RequestType
                    );

                if (!result.Succeeded)
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                    return(BadRequest(ModelState));
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.InnerException.Message));
            }
        }