Exemplo n.º 1
0
        public PartialViewResult PageDonations(int offSet = 0, int limit = 5)
        {
            var repository = new DonationsRepository();
            var model      = repository.GetDonations(offSet, limit);

            return(PartialView("Partials/DonationsTable", model));
        }
Exemplo n.º 2
0
        public PartialViewResult UpdateDonation(Donation Donation)
        {
            var repository = new DonationsRepository();

            repository.UpdateDonation(Donation);
            var model = repository.GetDonation(Donation.Id);

            return(PartialView("Partials/DonationTableRow", model.Donation));
        }
Exemplo n.º 3
0
        public PartialViewResult CreateDonation(Donation Donation)
        {
            var repository = new DonationsRepository();

            repository.CreateDonation(Donation);
            var model = repository.GetDonations();

            return(PartialView("Partials/DonationsTable", model));
        }
        public ActionResult LoadData()
        {
            JsonResult jsonResult;
            Single     amount;
            string     nif          = "";
            string     collaborator = "";
            string     periodicity  = "";

            string draw            = "";
            int    start           = 0;
            int    length          = 0;
            int    totalRecords    = 0;
            int    recordsFiltered = 0;
            //To save collaborator filtered.
            IQueryable <donaciones> donations;

            try
            {
                var search = Request["search[value]"];
                //jQuery DataTables Param
                draw = Request.Form.GetValues("draw").FirstOrDefault();
                //Find paging info
                start  = Convert.ToInt32(Request.Form.GetValues("start").FirstOrDefault());
                length = Convert.ToInt32(Request.Form.GetValues("length").FirstOrDefault());

                //Filter
                string amountStr = Request.Form.GetValues("columns[1][search][value]").FirstOrDefault();
                Single.TryParse(amountStr, NumberStyles.Any, CultureInfo.InvariantCulture, out amount);
                nif          = Request.Form.GetValues("columns[3][search][value]").FirstOrDefault();
                collaborator = Request.Form.GetValues("columns[4][search][value]").FirstOrDefault();
                periodicity  = Request.Form.GetValues("columns[6][search][value]").FirstOrDefault();

                //Sort
                var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][data]").FirstOrDefault();
                sortColumn = ConvertSortColumn(sortColumn);
                var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();

                donations = new DonationsRepository().GetPaginated(search, start, length, out totalRecords, out recordsFiltered, sortColumn,
                                                                   sortColumnDir, amount, nif, collaborator, periodicity);
            }
            catch (Exception)
            {
                donations       = db.donaciones.AsQueryable();
                recordsFiltered = donations.Count();
                totalRecords    = recordsFiltered;
            }

            List <DonationsViewModel> viewData = ConvertDonationsFromDBToView(donations.ToList());

            //Returning Json Data
            jsonResult = Json(new { draw = draw, recordsFiltered = recordsFiltered, recordsTotal = totalRecords, data = viewData });
            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Exemplo n.º 5
0
        public PartialViewResult GetDonationForEdit(int id)
        {
            var repository = new DonationsRepository();
            var model      = repository.GetDonation(id);

            if (model != null)
            {
                model.FoodBanks  = new FoodBanksRepository().GetFoodBanks(total: 1000).FoodBanks;
                model.Volunteers = new VolunteersRepository().GetVolunteers(total: 1000).Volunteers;
            }

            return(PartialView("Partials/Donation", model));
        }
Exemplo n.º 6
0
        public ActionResult Index()
        {
            var repository = new DonationsRepository();
            var model      = repository.GetDonations();

            if (model != null)
            {
                model.FoodBanks  = new FoodBanksRepository().GetFoodBanks(total: 1000).FoodBanks;
                model.Volunteers = new VolunteersRepository().GetVolunteers(total: 1000).Volunteers;
            }

            return(View("Index", model));
        }
Exemplo n.º 7
0
        public bool DeleteDonation(int id)
        {
            var repository = new DonationsRepository();

            return(repository.DeleteDonation(id));
        }