Exemplo n.º 1
0
        public Category Post([FromBody] Category dto)
        {
            var category = new Category
            {
                Name = dto.Name
            };

            _context.Categories.Add(category);
            _context.SaveChanges();

            return(category);
        }
Exemplo n.º 2
0
        public ActionResult <Restaurant> Post([FromBody] EditRestaurantDto dto)
        {
            Request.Headers.TryGetValue("User-Id", out var userId);
            var restaurant = new Restaurant
            {
                Name     = dto.Name,
                Email    = dto.Email,
                Phone    = dto.Phone,
                Location = new Location
                {
                    Latitude  = dto.Location.Lat,
                    Longitude = dto.Location.Lng
                },
                ManagerId = Guid.Parse(userId)
            };

            _context.Restaurants.Add(restaurant);
            _context.SaveChanges();
            return(Get(restaurant.Id));
        }