Ejemplo n.º 1
0
        public async Task SavePostAndLocation(AddPostAndLocation apal)
        {
            Location loc = new Location();

            loc.Address   = apal.Address;
            loc.Latitude  = apal.Latitude;
            loc.Longitude = apal.Longitude;

            var  LocationExists = _context.Location.FirstOrDefault(x => x.Address == loc.Address && x.Latitude == loc.Latitude && x.Longitude == loc.Longitude);
            Post post           = new Post();

            if (LocationExists == null)
            {
                _context.Location.Add(loc);
                await _context.SaveChangesAsync();

                post.LocationID = loc.ID;
            }
            else
            {
                post.LocationID = LocationExists.ID;
            }


            post.Title       = apal.Title;
            post.Description = apal.Description;
            post.Time        = apal.Time;
            post.Active      = apal.Active;
            post.PostImage   = apal.PostImage;
            post.UserDataID  = apal.UserDataID;
            post.CategoryID  = apal.CategoryID;

            post.CityID = apal.CityID;

            _context.Posts.Add(post);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Post> > PostPost(AddPostAndLocation apal)
        {
            await _IPostsUI.SavePostAndLocation(apal);

            return(Ok());
        }
Ejemplo n.º 3
0
 public Task SavePostAndLocation(AddPostAndLocation apal)
 {
     return(_IPostsDAL.SavePostAndLocation(apal));
 }