Exemple #1
0
        public IActionResult CreateGym(GymDto dto)
        {
            Log.Information("Attempting to create gym.");
            Gym g = _GymService.CreateGym(dto);

            if (g == null)
            {
                Log.Error("Failed to create gym.");
                return(BadRequest());
            }
            else
            {
                Log.Information("Gym created successfully.");
                return(Created("Gym created successfully.", g));
            }
        }
Exemple #2
0
        public IActionResult UpdateGym(int GymId, GymDto dto)
        {
            Log.Information("Attempting to update gym.");
            Gym g = _GymService.UpdateGym(GymId, dto);

            if (g == null)
            {
                Log.Error("Failed to update gym.");
                return(BadRequest());
            }
            else
            {
                Log.Information("Gym updated successfully. " + g);
                return(Ok(g));
            }
        }
Exemple #3
0
        public Gym CreateGym(GymDto dto)
        {
            Gym G = new Gym()
            {
                Name             = dto.Name,
                StreetAdress     = dto.StreetAdress,
                PostalCode       = dto.PostalCode,
                City             = dto.City,
                OperationalHours = dto.OperationalHours,
                MaxPeople        = dto.MaxPeople,
                Email            = dto.Email,
                PhoneNumber      = dto.PhoneNumber
            };

            _context.Gyms.Add(G);
            _context.SaveChanges();
            return(G);
        }
Exemple #4
0
        public Gym UpdateGym(int gymId, GymDto dto)
        {
            Gym g = _context.Gyms.Where(x => x.GymId == gymId).FirstOrDefault();

            if (g == null)
            {
                return(null);
            }
            g.Name             = dto.Name;
            g.Email            = dto.Email;
            g.StreetAdress     = dto.StreetAdress;
            g.PostalCode       = dto.PostalCode;
            g.City             = dto.City;
            g.MaxPeople        = dto.MaxPeople;
            g.OperationalHours = dto.OperationalHours;
            g.PhoneNumber      = dto.PhoneNumber;
            _context.Update(g);
            _context.SaveChanges();
            return(g);
        }