Beispiel #1
0
        public static UserPlaceViewModel ToViewModel(this UserPlace userPlace)
        {
            var vm = new UserPlaceViewModel()
            {
                UserPlaceId = userPlace.UserPlaceId,
                Name        = userPlace.Place.Name,
                Latitude    = userPlace.Place.Latitude,
                Longitude   = userPlace.Place.Longitude
            };

            return(vm);
        }
        public UserPlace CreateUserPlace(string userId, int placeId, string description)
        {
            UserPlace result = new UserPlace();

            result.UserId          = UserByUserId(userId).Id;
            result.PlaceId         = placeId;
            result.UserDescription = description;
            using (var db = DbConnectionFactory.OpenDbConnection())
            {
                result.Id = (int)db.Insert <UserPlace>(result);
            }
            return(result);
        }
Beispiel #3
0
        public void MakeUserPlace(UserPlaceDTO userPlaceDto)
        {
            UserPlace userPlace = new UserPlace
            {
                UserId         = userPlaceDto.UserId,
                Child          = userPlaceDto.Child,
                ClientName     = userPlaceDto.ClientName,
                Drink          = userPlaceDto.Drink,
                PlaceId        = userPlaceDto.PlaceId,
                TimeFinishTrip = userPlaceDto.TimeFinishTrip,
                TimeStartTrip  = userPlaceDto.TimeStartTrip,
                WithBed        = userPlaceDto.WithBed
            };

            _Database.UserPlaces.Create(userPlace);
            _Database.Save();
        }
Beispiel #4
0
        public UserPlace Create(UserPlaceViewModel toCreate)
        {
            ValidateUserPlace(toCreate);
            var userPlace = new UserPlace()
            {
                Place = new Place()
                {
                    Name      = toCreate.Name,
                    Latitude  = toCreate.Latitude,
                    Longitude = toCreate.Longitude,
                },
                OwnerId = _requestInformation.UserId,
                Active  = true
            };

            _db.UserPlaces.Add(userPlace);
            _db.SaveChanges();
            return(userPlace);
        }
        public async Task <IActionResult> Add(Place place)
        {
            if (ModelState.IsValid)
            {
                _db.Add(place);
                await _db.SaveChangesAsync();

                UserPlace userPlace = new UserPlace()
                {
                    Place   = place,
                    PlaceFK = place.Id,
                    User    = await _userManager.GetUserAsync(User),
                    UserFK  = _userManager.GetUserId(User)
                };
                _db.Add(userPlace);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(place));
        }