source: Farmatiko/Controllers/AdminController.cs@ 1454207

Last change on this file since 1454207 was 1454207, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Change structure, Add repo, services & controllers

  • Property mode set to 100644
File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5using FarmatikoData.Models;
6using FarmatikoServices.FarmatikoServiceInterfaces;
7using Microsoft.AspNetCore.Mvc;
8
9namespace Farmatiko.Controllers
10{
11 public class AdminController : Controller
12 {
13 private readonly IAdminService _adminService;
14 private readonly IService _service;
15 private readonly IPHService _phservice;
16 public AdminController(IAdminService adminService, IService service, IPHService phservice)
17 {
18 _adminService = adminService;
19 _service = service;
20 _phservice = phservice;
21 }
22
23 //GET
24 [HttpGet]
25 public async Task<IQueryable<PharmacyHead>> GetPharmacyHeads()
26 {
27 return await _adminService.GetPharmacyHeads();
28 }
29
30 [HttpGet]
31 public async Task<IQueryable<RequestPharmacyHead>> GetClaimingRequests()
32 {
33 return await _adminService.GetCalimingRequests();
34 }
35
36
37 //POST
38 [HttpPost]
39 public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead)
40 {
41 await _service.AddPharmacyHead(pharmacyHead);
42 return Ok();
43 }
44
45 [HttpPost]
46 public async Task<IActionResult> RemovePharmacyHead(PharmacyHead pharmacyHead)
47 {
48 await _service.RemovePharmacyHead(pharmacyHead);
49 return Ok();
50 }
51 [HttpPost]
52 public async Task<IActionResult> RejectRequset(RequestPharmacyHead req)
53 {
54 await _adminService.RejectRequest(req);
55 return Ok();
56 }
57 [HttpPost]
58 public async Task<IActionResult> ApproveRequest(PharmacyHead pharmacyHead)
59 {
60 await _phservice.UpdatePharmacyHead(pharmacyHead);
61 return Ok();
62 }
63
64 }
65}
Note: See TracBrowser for help on using the repository browser.