コード例 #1
0
ファイル: ParticipantService.cs プロジェクト: Desarc/Veita
 public void AddParticipant(Participant participant)
 {
     if (!ParticipantExists(participant))
     {
         _collection.Insert(participant);
     }
 }
コード例 #2
0
ファイル: ReceiptService.cs プロジェクト: Desarc/Veita
 public void AddParticipantToReceipt(Receipt receipt, Participant participant)
 {
     if (!receipt.Participants.Exists(p => p.Name == participant.Name))
     {
         receipt.Participants.Add(participant);
         _collection.Save(receipt);
     }
 }
コード例 #3
0
ファイル: ParticipantService.cs プロジェクト: Desarc/Veita
 private bool ParticipantExists(Participant participant)
 {
     var query = Query.EQ("Name", participant.Name);
     return _collection.FindOne(query) != null;
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: Desarc/Veita
        public void CreateTestData()
        {
            List<Receipt> testReceipts1; //betalt av Arnulf
            List<Receipt> testReceipts2; //Arnulf har deltatt på
            List<Participant> testParticipants1;
            List<Participant> testParticipants2;
            List<Participant> testParticipants3;

            var Stig = new Participant { Name = "Arnulf" };
            var Magnus = new Participant { Name = "Dingo" };
            var Jonas = new Participant { Name = "Hodor" };
            var Elisabeth = new Participant { Name = "Annie" };
            var Monika = new Participant { Name = "Abed" };
            var Oyvin = new Participant { Name = "Yussuf" };

            testParticipants1 = new List<Participant>();
            testParticipants2 = new List<Participant>();
            testParticipants3 = new List<Participant>();
            testReceipts1 = new List<Receipt>();
            testReceipts2 = new List<Receipt>();

            testParticipants1.Add(Stig);
            testParticipants1.Add(Magnus);
            testParticipants1.Add(Jonas);

            testParticipants2.Add(Elisabeth);
            testParticipants2.Add(Jonas);
            testParticipants2.Add(Stig);

            testParticipants3.Add(Oyvin);
            testParticipants3.Add(Monika);

            var middag1 = new Receipt
            {
                Date = DateTime.Now,
                Month = DateTime.Now.Month,
                Payer = Stig,
                Description = "test1",
                Price = 45.0,
                Participants = testParticipants1
            };
            var middag2 = new Receipt
            {
                Date = DateTime.Now,
                Month = DateTime.Now.Month,
                Payer = Stig,
                Description = "test2",
                Price = 85.0,
                Participants = testParticipants3
            };
            var middag3 = new Receipt
            {
                Date = DateTime.Now,
                Month = 14,
                Payer = Monika,
                Description = "test3",
                Price = 60.0,
                Participants = testParticipants1
            };
            var middag4 = new Receipt
            {
                Date = DateTime.Now,
                Month = DateTime.Now.Month,
                Payer = Elisabeth,
                Description = "test4",
                Price = 90.0,
                Participants = testParticipants1
            };
            var middag5 = new Receipt
            {
                Date = DateTime.Now,
                Month = 14,
                Payer = Stig,
                Description = "test5",
                Price = 65.0,
                Participants = testParticipants3
            };

            testReceipts1.Add(middag1);
            testReceipts1.Add(middag2);
            testReceipts1.Add(middag5);

            testReceipts2.Add(middag1);
            testReceipts2.Add(middag3);
            testReceipts2.Add(middag4);

            foreach (Participant participant in testParticipants1)
            {
                _participantservice.AddParticipant(participant);
            }
            foreach (Participant participant in testParticipants2)
            {
                _participantservice.AddParticipant(participant);
            }
            foreach (Participant participant in testParticipants3)
            {
                _participantservice.AddParticipant(participant);
            }
            foreach (Receipt receipt in testReceipts1)
            {
                _receiptService.AddReceipt(receipt);
            }
            foreach (Receipt receipt in testReceipts2)
            {
                _receiptService.AddReceipt(receipt);
            }
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: Desarc/Veita
 public ActionResult AddParticipant(Participant participant)
 {
     _participantservice.AddParticipant(participant);
     return RedirectToAction("AddParticipant");
 }