public ExperienceData Get()
 {
     return(new ExperienceData
     {
         Visits = visitsRepository.Get(),
         PersonalInfo = personalInfoRepository.Get(),
         OnsiteBehavior = onsiteBehaviorRepository.Get(),
         Referral = referralRepository.Get(),
         IsActive = trackerService.IsActive
     });
 }
Beispiel #2
0
        public async Task <IHttpActionResult> AddVisit([FromBody] VisitModel Visit)
        {
            bool result = await Task.Run(() =>
            {
                try
                {
                    var identityClaims = (ClaimsIdentity)User.Identity;
                    var newVisit       = new VisitModel()
                    {
                        User    = identityClaims.FindFirstValue("UserName"),
                        Town    = Visit.Town,
                        Country = Visit.Country,
                        Comment = Visit.Comment,
                        Raiting = Visit.Raiting
                    };

                    _VisitsRepository.Create(newVisit);
                    if (_VisitsRepository.Get(newVisit.Id) == null)
                    {
                        return(false);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                }
            });

            if (result)
            {
                return(Ok("Added"));
            }
            else
            {
                return(InternalServerError(new Exception("Can not add Visit to DB")));
            }
        }