-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotificationsController.cs
49 lines (42 loc) · 1.52 KB
/
NotificationsController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Microsoft.AspNet.SignalR;
using Newtonsoft.Json.Linq;
using Models.Domain;
using Models.Requests;
using Models.Responses;
using Services;
using Services.Security;
using Web.App_Start;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Remoting.Contexts;
using System.Web.Configuration;
using System.Web.Http;
namespace Web.Controllers
{
public class NotificationsController : ApiController
{
readonly INotificationsService notificationsService;
public NotificationsController(INotificationsService notificationsService)
{
this.notificationsService = notificationsService;
}
[Route("api/notifications/{id:int}"), HttpDelete]
public HttpResponseMessage Delete(int id)
{
int userId = User.Identity.GetId().Value;
notificationsService.Delete(id, userId);
return Request.CreateResponse(HttpStatusCode.OK, new SuccessResponse());
}
[Route("api/notifications/"), HttpGet]
public HttpResponseMessage NotificationExists(string type, int userId, int senderId)
{
bool notificationExists = notificationsService.NotificationExists(type, userId, senderId);
ItemResponse<bool> itemResponse = new ItemResponse<bool>();
itemResponse.Item = notificationExists;
return Request.CreateResponse(HttpStatusCode.OK, itemResponse);
}
}
}