예제 #1
0
 private void textBoxSearch_TextChanged(object sender, EventArgs e)
 {
     DAL.Doner doner = new Doner();
     doner.Search = textBoxSearch.Text;
     dataGridViewShowDonar.DataSource = doner.Select().Tables[0];
     buttonSearch.PerformClick();
 }
예제 #2
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (dataGridViewShowDonar.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult confrmDelete = MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButtons.YesNoCancel,
                                                        MessageBoxIcon.Question);

            if (confrmDelete != DialogResult.Yes)
            {
                return;
            }

            DAL.Doner doner = new Doner();
            string    ids   = "";

            for (int i = 0; i < dataGridViewShowDonar.SelectedRows.Count; i++)
            {
                ids += dataGridViewShowDonar.SelectedRows[i].Cells["ColId"].Value.ToString() + ", ";
            }

            ids = ids.Substring(0, ids.Length - 2);

            if (doner.Delete(ids))
            {
                MessageBox.Show("Donar is deleted");
                buttonSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(doner._Error);
            }
        }
예제 #3
0
        public async Task <IActionResult> Return(int?Id)
        {
            if (Id != null)
            {
                PartYearEvent partYearEvent = await db.PartYearEvents.FirstOrDefaultAsync(p => p.Id == Id);

                if (partYearEvent != null)
                {
                    if (await Success(partYearEvent))
                    {
                        Doner doner = new Doner();
                        PartYearEventViewModel partYearEventViewModel = new PartYearEventViewModel
                        {
                            Id                = partYearEvent.Id,
                            YearEventId       = partYearEvent.YearEventId,
                            NumberYearEvent   = partYearEvent.NumberYearEvent,
                            Done              = partYearEvent.Done,
                            Img               = partYearEvent.Img,
                            Pdf               = partYearEvent.Pdf,
                            PriceB            = partYearEvent.PriceB,
                            PriceNotB         = partYearEvent.PriceNotB,
                            DateTime          = partYearEvent.DateTime,
                            UserNameСonfirmed = partYearEvent.UserNameСonfirmed,
                            UserNameSent      = partYearEvent.UserNameSent,
                            Сomment           = partYearEvent.Сomment,
                            maxDone           = await doner.GetMaxDone(partYearEvent.Id, db)
                        };

                        return(View(partYearEventViewModel));
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #4
0
        private static void Main()
        {
            var myDoner = new Doner();

            myDoner.OrderDoner();
//            myDoner.DummyDoner();
            myDoner.MakeDoner();
        }
예제 #5
0
        public void AddToDb(DonerDTO donerDto)
        {
            var Doner = new Doner();

            Doner          = Mapper.Map <Doner>(donerDto);
            Doner.Location = Mapper.Map <Location>(donerDto.Location);
            context.DonerTab.Add(Doner);
            context.SaveChanges();
        }
예제 #6
0
        private async Task <IActionResult> SupprtEntry(int id)
        {
            var donation = await DbContext.Donations.FindAsync(id);

            if (donation == null)
            {
                return(NotFound());
            }

            var userContext = CoreService.GetUserContext();
            var escrowUser  = DbContext.VetMembers.FirstOrDefault(c => c.MemberType == MemberType.Escrow);

            if (DonateAmount <= 0)
            {
                IsSuppotError = true;
                ErrorMessage  = "数値の入力が必要です";
                return(await OnGetAsync(id));
            }

            if (userContext.Amount < DonateAmount)
            {
                IsSuppotError = true;
                ErrorMessage  = "残高不足です";
                return(await OnGetAsync(id));
            }
            var coinTransaction = new CoinTransaction
            {
                SendeVetMemberId   = userContext.CurrentUser.Id,
                RecivedVetMemberId = escrowUser.Id,
                Amount             = DonateAmount,
                Text            = $"{donation.Title} へ {PostMessage}",
                TransactionType = CoinTransactionType.Donate
            };

            var doner = new Doner
            {
                Amount          = DonateAmount,
                Comment         = PostMessage,
                DonationId      = donation.Id,
                VetMemberId     = userContext.CurrentUser.Id,
                CoinTransaction = coinTransaction
            };

            DbContext.Doners.Add(doner);
            DbContext.CoinTransactions.Add(coinTransaction);

            await DbContext.SaveChangesAsync();

            await Notification(userContext, donation, doner);

            return(RedirectToPage("Details", new { id = id }));
        }
예제 #7
0
        public ActionResult <Doner> ReceiveFile([FromForm] DonerInput data)
        {
            var newDoner = new Doner()
            {
                Name     = data.Name,
                LastName = data.LastName,
                ImgPath  = data.ImgPath,
                PayDate  = data.PayDate,
                Donation = data.Donation
            };

            _donerService.Create(newDoner);
            return(Ok(200));
        }
예제 #8
0
        public IActionResult Update([FromForm] Doner donerIn)
        {
            var newDoner = new Doner()
            {
                Name     = donerIn.Name,
                LastName = donerIn.LastName,
                ImgPath  = donerIn.ImgPath,
                PayDate  = donerIn.PayDate,
                Donation = donerIn.Donation,
            };

            _donerService.Update(donerIn.Id, donerIn);

            return(NoContent());
        }
예제 #9
0
        private async Task Notification(UserContext userContext, Donation donation, Doner doner)
        {
            var fields = new List <DiscordService.DiscordEmbed.Field>();

            fields.Add(new DiscordService.DiscordEmbed.Field
            {
                name   = "金額",
                value  = $"{doner.Amount}{StaticSettings.CurrenryUnit}",
                inline = false
            });

            if (!string.IsNullOrWhiteSpace(doner.Comment))
            {
                fields.Add(new DiscordService.DiscordEmbed.Field
                {
                    name   = "メッセージ",
                    value  = doner.Comment,
                    inline = false
                });
            }

            var total = DbContext.Doners.AsQueryable().Where(c => c.DonationId == donation.Id)
                        .Where(c => c.DonerState != DonerState.Cancel)
                        .Where(c => c.VetMemberId != donation.VetMemberId)
                        .Sum(c => c.Amount);

            fields.Add(new DiscordService.DiscordEmbed.Field
            {
                name   = "支援総額",
                value  = $"{total}{StaticSettings.CurrenryUnit}",
                inline = false
            });


            await DiscordService.SendMessage(DiscordService.Channel.CrowdFundingNotification, string.Empty, new DiscordService.DiscordEmbed
            {
                title  = donation.Title,
                url    = $"{StaticSettings.SiteBaseUrl}Donations/Details?id={donation.Id}",
                author = new DiscordService.DiscordEmbed.Author
                {
                    url      = userContext.CurrentUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl),
                    icon_url = userContext.CurrentUser.GetAvaterIconUrl(),
                    name     = userContext.CurrentUser.Name
                },
                fields = fields.ToArray()
            });
        }
예제 #10
0
 public void Remove(Doner donerIn) =>
 _doner.DeleteOne(doner => doner.Id == donerIn.Id);
예제 #11
0
 public void Update(string id, Doner donerIn) =>
 _doner.ReplaceOne(doner => doner.Id == id, donerIn);
예제 #12
0
 public void Create(Doner newDoner) => _doner.InsertOne(newDoner);
예제 #13
0
        public async Task <IActionResult> Index(string userName, string dataYear)
        {
            if (userName == User.Identity.Name)
            {
                if (User.Identity.Name != null)
                {
                    List <YearEvent> yearEvents = await db.YearEvents.Where(y => y.DataYear == dataYear).ToListAsync();

                    if (yearEvents.Count == 0)
                    {
                        dataYear   = DateTime.Now.Year.ToString();
                        yearEvents = await db.YearEvents.Where(y => y.DataYear == dataYear).ToListAsync();

                        if (yearEvents.Count == 0)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }

                    List <Agency> agencies = await db.Agencies.ToListAsync();

                    agencies = AgencyFilter.GetAgenciesFilterYearEvent(agencies, yearEvents);

                    var agenciessort = from a in agencies
                                       orderby a.Name
                                       select a;// сортировка по имени учреждения
                    agencies = agenciessort.ToList();

                    if (agencies != null)
                    {
                        List <YearEventViewModel> YearEventViewModels = new List <YearEventViewModel>();

                        Procenter procenter = new Procenter();
                        foreach (YearEvent yearEvent in yearEvents)
                        {
                            YearEventViewModels.Add(new YearEventViewModel()
                            {
                                Id             = yearEvent.Id,
                                AgencyId       = yearEvent.AgencyId,
                                Number         = yearEvent.Number,
                                EventText      = yearEvent.EventText,
                                FirstQuarter   = yearEvent.FirstQuarter,
                                SecondQuarter  = yearEvent.SecondQuarter,
                                ThirdQuarter   = yearEvent.ThirdQuarter,
                                FourthQuarter  = yearEvent.FourthQuarter,
                                Unit           = yearEvent.Unit,
                                Section        = yearEvent.Section,
                                SubSection     = yearEvent.SubSection,
                                SubSection1    = yearEvent.SubSection1,
                                TypeSection    = yearEvent.TypeSection,
                                DataYear       = yearEvent.DataYear,
                                PartYearEvents = await db.PartYearEvents.Where(p => p.YearEventId == yearEvent.Id).ToListAsync(),
                                Procent        = await procenter.GetProcentYearEvent(yearEvent.Id, db),
                                TrClass        = await Overdue.GetOverdueYearEventColor(yearEvent.Id, db)
                            });
                        }
                        Pricer pricer = new Pricer();
                        Doner  doner  = new Doner();
                        List <AgencyYearPlanViewModel> agencyYearPlanViewModels = new List <AgencyYearPlanViewModel>();
                        foreach (Agency ag in agencies)
                        {
                            agencyYearPlanViewModels.Add(new AgencyYearPlanViewModel()
                            {
                                Id   = ag.Id,
                                Name = ag.Name,
                                YearEventViewModels = YearEventViewModels.Where(y => y.AgencyId == ag.Id).ToList(),
                                FullDonePlan        = await db.YearEvents.Where(y => y.AgencyId == ag.Id).
                                                      Where(y => y.DataYear == dataYear).
                                                      CountAsync(),
                                NowDonePlan      = await doner.GetYearAgencyDoneNow(ag, db, dataYear),
                                Procent          = await procenter.GetProcentAgency(ag.Id, db, dataYear),
                                FullPriceBnow    = await pricer.GetFullPriceBNowAgency(ag.Id, db, dataYear),
                                FullPriceNotBnow = await pricer.GetFullPriceNotBNowAgency(ag.Id, db, dataYear)
                            });
                        }

                        TotalYearPlanViewModel totalYearPlanViewModel = new TotalYearPlanViewModel();
                        totalYearPlanViewModel.AgencyYearPlanViewModels = agencyYearPlanViewModels;
                        totalYearPlanViewModel.Procent = await procenter.GetProcentTotal(agencies, db, dataYear);

                        totalYearPlanViewModel.FullDonePlan = await doner.GetYearPlanCount(agencies, db, dataYear);

                        totalYearPlanViewModel.NowDonePlan = await doner.GetYearPlanDoneCount(agencies, db, dataYear);

                        totalYearPlanViewModel.FullPriceBnow = await pricer.GetFullPriceBNowTotal(agencies, db, dataYear);

                        totalYearPlanViewModel.FullPriceNotBnow = await pricer.GetFullPriceNotBNowTotal(agencies, db, dataYear);

                        totalYearPlanViewModel.FullPrice = totalYearPlanViewModel.FullPriceBnow + totalYearPlanViewModel.FullPriceNotBnow;
                        totalYearPlanViewModel.DataYear  = dataYear;
                        totalYearPlanViewModel.DataYears = await db.DataYears.ToListAsync();

                        return(View(totalYearPlanViewModel));
                    }
                }
            }
            return(RedirectToAction("Index", "Home"));
        }