Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateAvailability(Guid id, [FromBody] AvailabilityDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var availability = _dataContext.Availabilities.FindAsync(model.Id);


            await TryUpdateModelAsync(availability);

            await _dataContext.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateAvailability([FromBody] AvailabilityDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var availability = new Availability()
            {
                StartTime = model.StartTime,
                EndTime   = model.EndTime,
                UserId    = model.UserId
            };

            _dataContext.Availabilities.Add(availability);
            await _dataContext.SaveChangesAsync();

            return(Ok());
        }