public HttpResponseMessage GetAll(HttpRequestMessage request, string keyword, int page, int pageSize = 20)
        {
            return(CreateHttpResponse(request, () =>
            {
                int totalRow = 0;

                var model = _donationService.GetAll(keyword);

                totalRow = model.Count();

                var query = model.OrderByDescending(x => x.CreatedDate).Skip(page * pageSize).Take(pageSize);

                var responseData = Mapper.Map <List <DonationViewModel> >(query.ToList());

                var paginationSet = new PaginationSet <DonationViewModel>()
                {
                    Items = responseData,
                    Page = page,
                    TotalCount = totalRow,
                    TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize)
                };

                var response = request.CreateResponse(HttpStatusCode.OK, paginationSet);
                return response;
            }));
        }
Beispiel #2
0
        public ActionResult Index()
        {
            var controlPanelModel     = _commonService.getControPanel(2);
            var controlPanelViewModel = Mapper.Map <ControlPanel, ControlPanelViewModel>(controlPanelModel);
            var getAll = _donationService.GetAll(null);

            decimal?sum = 0;

            foreach (var item in getAll)
            {
                sum = sum + item.Price;
            }
            ViewBag.sum = sum;
            return(View(controlPanelViewModel));
        }
Beispiel #3
0
        public void ItReturnsResultFromDonationService()
        {
            // Arrange
            var donations = new List <Donation>
            {
                new()
                {
                    Title = "Donation Title", Description = "Donations Description"
                }
            };

            _donationService.GetAll().Returns(donations);

            // Act
            var result = _sut.Get() as OkObjectResult;

            // Assert
            result.Value.Should().BeEquivalentTo(donations);
        }
    }
        public IActionResult Index()
        {
            IEnumerable <Donation> AllDonations = _donationService.GetAll();
            int qq = 0;
            var ii = AllDonations.Select(x => x.Id).Distinct();

            foreach (Donation d in AllDonations)
            {
                qq += d.Quantity;
                //ii += d.Institutions.Id;
            }

            IndexModel indexModel = new IndexModel
            {
                Quantity        = qq,
                AllInstitutions = ii.Count(),
                InstitutionList = _instytutionService.GetAll()
            };

            return(View(indexModel));
        }
Beispiel #5
0
 public ActionResult GetAllDonation()
 {
     try
     {
         var    result      = _donationService.GetAll();
         double totalamount = 0;
         foreach (var v in result.Data)
         {
             totalamount += v.Amount;
         }
         ViewBag.TotalAmount = totalamount;
         if (result.HasError)
         {
             ViewBag.Message = result.Message;
             return(Content(result.Message));
         }
         return(Content("Hello"));
     }
     catch (Exception e)
     {
         return(Content(e.Message));
     }
 }
        public IActionResult Get()
        {
            var donations = _donationService.GetAll();

            return(Ok(donations));
        }
Beispiel #7
0
 public void OnGet()
 {
     BankAccount = _configuration["BankAccount"];
     Donations   = _donationService.GetAll();
 }
Beispiel #8
0
 public GetTests()
 {
     _donationService = Substitute.For <IDonationService>();
     _donationService.GetAll().Returns(new List <Donation>());
     _sut = new DonationsController(_donationService);
 }