Ejemplo n.º 1
0
        public ActionResult CreateDonation(DonationModel AdminDonationModel, HttpPostedFileBase BannerImage)
        {
            DonationModel DonationCreation = new DonationModel();

            if (ModelState.IsValid)
            {
                var fileName = Path.GetFileName(BannerImage.FileName);
                var path     = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                BannerImage.SaveAs(path);
                var FilePath = "/UserProfilePictures/" + fileName;


                Donation_Details Donations = new Donation_Details()
                {
                    Donation_Title       = AdminDonationModel.DonationTitle,
                    Donation_Banner      = FilePath,
                    Donation_Description = AdminDonationModel.DonationDescription,
                    Donation_Amount      = AdminDonationModel.DonationAmount,
                    Status    = true,
                    CreatedOn = DateTime.Now
                };

                Donation_Details AdminDonations = Donationservice.Create(Donations);
            }

            return(RedirectToAction("GetDonations"));
        }
Ejemplo n.º 2
0
        public DonationModel Add(DonationViewModel donationView)
        {
            DonationModel donation           = null;
            var           institutionService = new InstitutionService(Context);
            var           categoryService    = new CategoryService(Context);

            try
            {
                List <CategoryModel> categories = new List <CategoryModel>();
                foreach (string id in donationView.CategoriesIds)
                {
                    if (id != "false")
                    {
                        categories.Add(categoryService.GetOne(Int32.Parse(id)));
                    }
                }
                donation = new DonationModel()
                {
                    Quantity      = donationView.Quantity,
                    Institution   = institutionService.GetOne(donationView.InstitutionId),
                    Categories    = categories,
                    Street        = donationView.Street,
                    City          = donationView.City,
                    ZipCode       = donationView.ZipCode,
                    PickUpTime    = donationView.PickUpTime,
                    PickUpComment = donationView.PickUpComment,
                    Phone         = donationView.Phone
                };
                Context.Donations.Add(donation);
                Context.SaveChanges();
            }
            catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.InnerException); }
            return(donation);
        }
Ejemplo n.º 3
0
        public ActionResult Main()
        {
            DonationModel donationModel = DonationService.GetConsoleNumShow();

            ViewBag.DonationTop = DonationService.GetSumPriceTop(5).ToList();
            return(View(donationModel));
        }
Ejemplo n.º 4
0
        public ActionResult CreateDonation(DonationModel AdminDonationModel, HttpPostedFileBase BannerImage)
        {
            DonationModel DonationCreation = new DonationModel();
            if (ModelState.IsValid)
            {
                var fileName = Path.GetFileName(BannerImage.FileName);
                var path = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                BannerImage.SaveAs(path);
                var FilePath = "/UserProfilePictures/" + fileName;

                Donation_Details Donations = new Donation_Details()
                {
                    Donation_Title = AdminDonationModel.DonationTitle,
                    Donation_Banner = FilePath,
                    Donation_Description = AdminDonationModel.DonationDescription,
                    Donation_Amount = AdminDonationModel.DonationAmount,
                    Status = true,
                    CreatedOn = DateTime.Now
                };

                Donation_Details AdminDonations = Donationservice.Create(Donations);
            }

            return RedirectToAction("GetDonations");
        }
        public Task CreateDonationAsync(DonationModel donation, int institutionId, List <int> categoryIds)
        {
            try
            {
                // Create donation entity
                donation.Institution = GetInstitution(institutionId);
                _context.Donations.Add(donation);
                var result = _context.SaveChanges();
                // Create entities for joining table between donations and categories
                var categoryDonations = new List <CategoryDonationModel>();
                categoryIds.ForEach(c => categoryDonations.Add(new CategoryDonationModel()
                {
                    CategoryId = c, DonationId = donation.Id
                }));
                _context.AddRange(categoryDonations);
                result += _context.SaveChanges();

                if (result > 1)
                {
                    _logger.LogInformation("Donation created in the database.");
                }

                return(Task.CompletedTask);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error creating a donation.");
                return(Task.FromException(e));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Add(DonationModel model)
        {
            model.CreateTime = DateTime.Now;
            var result = DonationService.Insert(model) ? SuccessTip("添加成功") : ErrorTip("添加失败");

            return(Json(result));
        }
Ejemplo n.º 7
0
        public async Task <bool> Create(DonationView result)
        {
            var donation = new DonationModel
            {
                Quantity      = result.Bags,
                Institution   = await _context.Instituties.FindAsync(result.SelectedInstitutionId),
                Street        = result.Address,
                City          = result.City,
                ZipCode       = result.Postcode,
                PickUpDate    = result.Data,
                PickUpTime    = result.Time,
                PickUpComment = result.Moreinfo
            };

            foreach (var category in result.CategoriesSelected)
            {
                var toDb = new CategoryDonationModel
                {
                    Donation = donation,
                    Category = await _context.Categories.FindAsync(category)
                };
                _context.CategoryDonation.Add(toDb);
            }


            _context.Donations.Add(donation);
            return(await _context.SaveChangesAsync() > 0);
        }
Ejemplo n.º 8
0
        public ActionResult UpdateDonation(DonationModel AdminDonationModel, HttpPostedFileBase BannerImage)
        {
            if (AdminDonationModel.DonationID != null)
            {
                var FilePath = "";
                if (BannerImage != null)
                {
                    var fileName = Path.GetFileName(BannerImage.FileName);
                    var path     = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                    BannerImage.SaveAs(path);
                    FilePath = "/UserProfilePictures/" + fileName;
                }

                Donation_Details Donations = new Donation_Details()
                {
                    Donation_ID          = AdminDonationModel.DonationID,
                    Donation_Title       = AdminDonationModel.DonationTitle,
                    Donation_Description = AdminDonationModel.DonationDescription,
                    Donation_Amount      = AdminDonationModel.DonationAmount,
                    Donation_Banner      = FilePath,
                    Status    = true,
                    UpdatedOn = DateTime.Now
                };
                Donationservice.DonationsUpdate(Donations);
            }

            else
            {
            }
            TempData["SuccessMessage"] = "Donation Updated Successfully..";
            return(RedirectToAction("GetDonations", "Donations", new { area = "Admin" }));
        }
Ejemplo n.º 9
0
        public IActionResult Create(int id)
        {
            var campaign = campaigns.GetById(id);
            var model    = new DonationModel();

            model.CampaignId   = campaign.Id;
            model.CampaignName = campaign.Name;
            return(View(model));
        }
Ejemplo n.º 10
0
        public ActionResult Donate(int id)
        {
            var model = new DonationModel()
            {
                CampaignId = id
            };

            return(View(model));
        }
        public ActionResult Update(int id)
        {
            //finding the opened donation
            DonationModel OpenedDonation = db.Donation.Find(id);

            Debug.WriteLine("updating the donation with id" + id);
            //returnig the view
            return(View(OpenedDonation));
        }
 public void ClearNewDonation()
 {
     NewDonation = new DonationModel();
     NotifyOfPropertyChange(() => NewDonation);
     NotifyOfPropertyChange(() => NewDonationName);
     NotifyOfPropertyChange(() => NewDonator);
     NotifyOfPropertyChange(() => NewDescription);
     NotifyOfPropertyChange(() => NewDate);
     NotifyOfPropertyChange(() => NewAmount);
 }
Ejemplo n.º 13
0
 public Task SendDonationConfirmation(DonationModel donation)
 {
     _emailService.SendAsync(
         donation.User.Email,
         $"{donation.User.Name}, dziękujemy za darowiznę",
         $"<h3>Witaj {donation.User.Name}<h3><br /> Przyjęliśmy zlecenie odbioru worków w ilości: {donation.Quantity}<br />" +
         $"Przygotuj worki do odbioru przez kuriera {donation.PickUpOn:yyyy.MM.dd} około {donation.PickUpOn:HH:00}.<br />" +
         "Dziękujemy.",
         true);
     return(Task.CompletedTask);
 }
        public ActionResult Delete(int id)
        {
            //finding the donation
            DonationModel Donation = db.Donation.Find(id);

            Debug.WriteLine("deleting the job with id" + id);
            // removing the donation
            db.Donation.Remove(Donation);
            db.SaveChanges();
            //returning the list view
            return(RedirectToAction("List"));
        }
Ejemplo n.º 15
0
        public ActionResult AddEditDonation(int DonationID)
        {
            BloodDonorDBEntities db = new BloodDonorDBEntities();

            List <Donor> listDonor = db.Donors.ToList();

            ViewBag.DonorsList = new SelectList(listDonor.Where(x => x.DonorIsDeleted == false), "DonorID", "DonorFullName");

            List <Recipient> listRecipient = db.Recipients.ToList();

            ViewBag.RecipientsList = new SelectList(listRecipient, "RecipientID", "RecipientCodedName");

            List <DonationSite> listDonationSite = db.DonationSites.ToList();

            ViewBag.DonationSiteList = new SelectList(listDonationSite, "DonationSiteID", "SiteName");

            List <string> listDonationTypes = new List <string>(new string[] { "Whole Blood", "Packed Red Blood Cells", "Platelets", "Plasma" });

            ViewBag.DonationTypeList = new SelectList(listDonationTypes);

            List <string> bloodType = new List <string>(new string[] { "A", "AB", "B", "0" });

            ViewBag.BloodTypeList = new SelectList(bloodType);

            List <string> rhFactor = new List <string>(new string[] { "+(positive)", "-(negative)" });

            ViewBag.RhFactorList = new SelectList(rhFactor);

            List <string> accepted = new List <string>(new string[] { "True", "False" });

            ViewBag.IsAcceptedList = new SelectList(accepted);

            DonationModel model = new DonationModel();

            if (DonationID > 0)
            {
                Donation donation = db.Donations.SingleOrDefault(x => x.DonationID == DonationID && x.IsDeleted == false);
                model.DonationID         = donation.DonationID;
                model.DonorID            = donation.DonorID;
                model.DonationType       = donation.DonationType;
                model.CrossBloodType     = donation.CrossBloodType;
                model.CrossRhFactor      = donation.CrossRhFactor;
                model.ExpirationDate     = donation.ExpirationDate;
                model.NumberOfUnits      = donation.NumberOfUnits;
                model.DonationSiteID     = donation.DonationSiteID;
                model.RecipientID        = donation.RecipientID;
                model.CreationDate       = donation.CreationDate;
                model.Accepted           = donation.Accepted;
                model.ReasonForRejection = donation.ReasonForRejection;
            }

            return(PartialView("_AddEditDonation", model));
        }
        private async Task FilterData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                Donations = DonationModel.GetDatedDonations(Since, To);
            });

            IsWorking = false;
        }
        private async Task GetData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                Donations = DonationModel.GetDonations();
            });

            IsWorking = false;
        }
        public ActionResult Create([Bind(Include = "DonatorName,DonatorEmail,DonationDate,DonatorPhone,DonationAmount")] DonationModel donation)
        {
            if (ModelState.IsValid)
            {
                //creating a new donation
                Debug.WriteLine("adding the donation" + donation);
                db.Donation.Add(donation);
                db.SaveChanges();
                return(RedirectToAction("List"));
            }

            return(View(donation));
        }
        private async Task LoadData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                Donations      = DonationModel.GetDonations();
                DonatorList    = PersonModel.ReturnDonators();
                NewDonatorList = PersonModel.ReturnDonators();
            });

            IsWorking = false;
        }
        private async Task LoadData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                AdoptionList = AdoptionModel.ReturnPersonAdoptions(Person.ID);
                WalkList     = WalkModel.ReturnPersonWalks(Person.ID);
                DonationList = DonationModel.ReturnPersonDonations(Person.ID);
            });

            IsWorking = false;
        }
Ejemplo n.º 21
0
        public IActionResult Create(DonationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var entity = new Donation();

            entity.Description = model.Description;
            entity.Campaign    = campaigns.GetById(model.CampaignId);
            entity.Id          = donations.Count() + 1;
            donations.Add(entity);
            return(RedirectToAction("Index"));
        }
        //update of donation
        public ActionResult Update(int id, string DonatorName, string DonatorEmail, DateTime DonationDate, int DonatorPhone, int DonationAmount)
        {
            Debug.WriteLine("updating donation with id" + id);
            //updating the applicant
            DonationModel Donation = db.Donation.Find(id);

            Donation.DonatorName    = DonatorName;
            Donation.DonatorEmail   = DonatorEmail;
            Donation.DonationDate   = DonationDate;
            Donation.DonatorPhone   = DonatorPhone;
            Donation.DonationAmount = DonationAmount;
            //saving to database
            db.SaveChanges();
            //returning to list
            return(RedirectToAction("List"));
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //finding the donation
            Debug.WriteLine("deleting job with id" + id);
            DonationModel donation = db.Donation.Find(id);

            if (donation == null)
            {
                return(HttpNotFound());
            }
            //returning the view
            return(View(donation));
        }
        public void DeleteDonation()
        {
            MessageBoxResult result = MessageBox.Show("Opravdu chcete vymazat zvolený dar?",
                                                      "Confirmation",
                                                      MessageBoxButton.YesNo,
                                                      MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                DonationModel.MarkAsDeleted((int)SelectedDonation.ID);

                Donation         = new DonationModel();
                SelectedDonation = null;

                Filter();
            }
        }
Ejemplo n.º 25
0
        public int pageSize = 10; //elements per page

        // GET: Admin/Donations
        /// <summary>
        ///     index page. get plans and donations
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var donations = from s in _context.Donations
                            orderby s.DonationTime descending
                            select s;

            var plans = from s in _context.Subscriptions
                        orderby s.Amount
                        select s;
            var model = new DonationModel
            {
                Donations     = donations.ToPagedList(1, pageSize),
                Plans         = plans.ToPagedList(1, pageSize),
                Subscriptions = new List <Subscription>()
            };

            return(View(model));
        }
        public ActionResult Details(int?id)
        {
            //error handelling
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //finding the donation
            DonationModel donation = db.Donation.Find(id);

            Debug.WriteLine("donation is" + donation);
            if (donation == null)
            {
                return(HttpNotFound());
            }
            //returning the view of donation
            return(View(donation));
        }
Ejemplo n.º 27
0
        public ActionResult Donate(DonationModel model)
        {
            using (var db = new ApplicationDbContext())
            {
                var campaign = db.CampaignModels.SingleOrDefault(x => x.Id == model.CampaignId);
                if (campaign == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                if (model.Sum < 0)
                {
                    return(RedirectToAction("Donate", "Campaign", new { id = model.CampaignId }));
                }

                campaign.CurrentSum += model.Sum;
                db.CampaignModels.AddOrUpdate(campaign);
                db.SaveChanges();
                return(RedirectToAction("Details", "Campaign", new { id = campaign.Id }));
            }
        }
Ejemplo n.º 28
0
        public async void Restore()
        {
            if (Since == null || To == null || (Since > To))
            {
                MessageBox.Show("Zvolte prosím platné datum.");
            }
            else
            {
                IsWorking = true;
                await Task.Delay(150);

                await Task.Run(() =>
                {
                    AdoptionModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    AnimalModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    BreedModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    CoatTypeModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    CostModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DeathModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DiaryModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DonationModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    EscapeModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    FurColorModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    IncidentModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    PersonModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    MedicalRecordModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    SpeciesModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    StayModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    WalkModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                });

                ComboBoxSettings();
                IsWorking = false;
                MessageBox.Show("Záznamy od " + Since + " do " + To + " obnoveny.");
            }
        }
Ejemplo n.º 29
0
        public ActionResult UpdateDonation(DonationModel AdminDonationModel, HttpPostedFileBase BannerImage)
        {
            if (AdminDonationModel.DonationID != null)
            {
                var FilePath = "";
                if (BannerImage != null)
                {
                    var fileName = Path.GetFileName(BannerImage.FileName);
                    var path = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                    BannerImage.SaveAs(path);
                    FilePath = "/UserProfilePictures/" + fileName;
                }

                Donation_Details Donations = new Donation_Details()
                {
                    Donation_ID = AdminDonationModel.DonationID,
                    Donation_Title = AdminDonationModel.DonationTitle,
                    Donation_Description = AdminDonationModel.DonationDescription,
                    Donation_Amount = AdminDonationModel.DonationAmount,
                    Donation_Banner = FilePath,
                    Status = true,
                    UpdatedOn = DateTime.Now
                };
                Donationservice.DonationsUpdate(Donations);
            }

            else
            {

            }
            TempData["SuccessMessage"] = "Donation Updated Successfully..";
            return RedirectToAction("GetDonations", "Donations", new { area = "Admin" });
        }
Ejemplo n.º 30
0
        public ActionResult Edit(DonationModel model)
        {
            var result = DonationService.UpdateById(model) ? SuccessTip("修改成功") : ErrorTip("修改失败");

            return(Json(result));
        }
 public DonationsViewModel()
 {
     Donation    = new DonationModel();
     NewDonation = new DonationModel();
 }
Ejemplo n.º 32
0
        public JsonResult List(DonationModel model, PageInfo pageInfo)
        {
            var result = DonationService.GetListByFilter(model, pageInfo);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 33
0
 public ActionResult UpdateDonation(int DonationId)
 {
     DonationModel AdminDonation = new DonationModel();
     return View(AdminDonation);
 }
Ejemplo n.º 34
0
 public ActionResult CreateDonation()
 {
     DonationModel DonationCreation = new DonationModel();
     return View(DonationCreation);
 }