Exemplo n.º 1
0
        public async Task <IActionResult> DeleteOffer(int schoolId, int offerId)
        {
            var school = await database.SchoolRepository.Get <School>(schoolId);

            int currentUserId = int.Parse(HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (currentUserId != school.OwnerId)
            {
                return(this.Forbidden("Nie jesteś właścicielem tej szkółki"));
            }

            if (await schoolService.DeleteOffer(offerId, school))
            {
                await notificationSystem.PushNotificationToUsersByFollows(StaticExpressions.OfferDeleted(school.Name), school);

                return(NoContent());
            }

            return(BadRequest("Nie udało się usunąć oferty"));
        }