public ActionResult <PostWorkingHours> PostWorkingHours(PostWorkingHours model) { try { IMapper mapper = EDeliveryProfile.PostWorkingHours(); var newWorkingHours = mapper.Map <WorkingHours>(model); var userIdClaim = User.FindFirst("MemberId")?.Value; var memberId = int.TryParse(userIdClaim, out var id) ? id : 0; EDeliveryDBContext dBContext = new EDeliveryDBContext(); var restaurantId = dBContext.Restaurant.First(o => o.MemberId == memberId).RestaurantId; newWorkingHours.RestaurantId = restaurantId; _repository.PostWorkingHours(newWorkingHours); return(new ObjectResult(new { message = "success", statusCode = HttpStatusCode.OK, response = "Succesfuly created working hours" })); } catch (Exception ex) { _logger.LogError($"Failed to create new working hours: {ex}"); return(BadRequest("Failed to create new working hours")); } }