示例#1
0
        public async Task <IActionResult> Create(string email)
        {
            var trackerProfile = _userTrackingRepository.GetUserProfile(User.Identity.Name);

            //todo - try to find user by email, if this is a new user create a profile and send email invite
            var user = await _userManager.FindByEmailAsync(email);

            if (user != null)
            {
                //Create an invitation and send notification using application
                var trackeeProfile = _userTrackingRepository.GetUserProfile(user.UserName);
                var existing       = _invitationRepository.Get(trackerProfile.UserName, trackeeProfile.Id);

                if (existing != null)
                {
                    _logger.LogWarning("an inviate already exists");
                }
                else
                {
                    _invitationRepository.Add(new TrackingInvitation()
                    {
                        Status    = eInvitationStatus.Invited,
                        TrackerId = trackerProfile.Id,
                        TrackeeId = trackeeProfile.Id,
                        Trackee   = trackeeProfile
                    });
                    _mailServices.Send(User.Identity.Name, user.UserName, trackeeProfile.Id);
                }
            }
            else
            {
                //_userTrackingRepository.
                _userTrackingRepository.AddUserProfile(new UserProfile()
                {
                    AvatarType = Shared.Avatar.child.ToString(),
                    Created    = DateTime.MinValue, // indicates its not created yet..
                    Status     = "new user",
                    UserName   = email
                });



                var trackeeProfile = _userTrackingRepository.GetUserProfile(email);

                //just create the profile and invitation and send an email
                _invitationRepository.Add(new TrackingInvitation()
                {
                    email     = email,
                    Status    = eInvitationStatus.Invited,
                    TrackerId = trackerProfile.Id,
                    TrackeeId = trackeeProfile.Id,
                    Trackee   = trackeeProfile
                });
                _mailServices.Send(User.Identity.Name, email, trackeeProfile.Id);
            }

            // todo - move to an API call!
            return(RedirectToAction("Index"));
        }
        public IActionResult Delete(int cityId, int id)
        {
            if (!cityRepository.CityExist(cityId))
            {
                return(NotFound());
            }
            var pointOfInterest = cityRepository.GetPointsOfInterest(cityId, id);

            if (pointOfInterest == null)
            {
                return(NotFound());
            }
            cityRepository.DeletePointOfInterest(pointOfInterest);
            mail.Send("delete", $"Point of name = {pointOfInterest.Name} deleted");
            if (!cityRepository.Save())
            {
                return(StatusCode(500, "proplem happend whern creating object"));
            }
            return(NoContent());
        }
        public IActionResult GetPointofIntrest(int Cityid)
        {
            try
            {
                _localmailservice.Send("", "");
                var city = CitiesDataStore.Current.Cities.FirstOrDefault(c => c.Id == Cityid);
                if (city == null)
                {
                    _logger.LogInformation($"City with id {Cityid} wsnt found");
                    return(NotFound());
                }

                else
                {
                    return(Ok(city.PointofIntest));
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"City with id {Cityid} wsnt found because", ex);
                return(StatusCode(500, "A problem has occured"));
            }
        }
        public IActionResult DeletePointOfInterest(int cityId, int id)
        {
            var city = CitiesDataStore.Current.Cities.FirstOrDefault(c => c.Id == id);

            if (city == null)
            {
                return(NotFound());
            }

            var pointOfInterestFromStore = city.PointsOfInterest.FirstOrDefault(p => p.Id == id);

            if (pointOfInterestFromStore == null)
            {
                return(NotFound());
            }

            city.PointsOfInterest.Remove(pointOfInterestFromStore);

            _mailService.Send("Point of interest deleted.",
                              $"Point of interest {pointOfInterestFromStore.Name} with id {pointOfInterestFromStore.Id} was deleted.");

            return(NoContent());
        }
        public IActionResult Delete(int countryId, int id)
        {
            var country = CountriesDataStore.Current.Countries.SingleOrDefault(x => x.Id == countryId);

            if (country == null)
            {
                return(NotFound());
            }

            var languaguesStore = country.OfficialLanguages.SingleOrDefault(x => x.Id == id);

            if (languaguesStore == null)
            {
                return(NotFound());
            }

            country.OfficialLanguages.Remove(languaguesStore);

            _mailServices.Send($"Language Deleted.",
                               $"Languages {languaguesStore.LanguageName} " +
                               $"with id {languaguesStore.Id}");

            return(NoContent());
        }
示例#6
0
        public IActionResult DeletePointOfInteres(int cityId, int id)
        {
            var city = _cityService.GetById(cityId, true);

            if (city == null)
            {
                return(NotFound());
            }

            var pointOfInterest = _pointOfInterestservice.GetById(id, true);

            if (pointOfInterest == null)
            {
                return(NotFound());
            }
            _pointOfInterestservice.Delete(id);
            _mailService
            .Send(
                $"Delete point if interest from city {city}",
                $"Delete point if interest from city {city} of point of interest with id {id}"
                );

            return(NoContent());
        }