Ejemplo n.º 1
0
        public FeeInfo CalcFee(Participant participant)
        {
            var seminarFee = participant.IsStudent || participant.IsInstructor || participant.IsConcerned ? 0 : SeminarFee;

            var socialGatheringFee = 0;
            if (participant.SocialGathering)
            {
                socialGatheringFee = participant.IsStudent ? SocialGatheringFeeForStudent : SocialGatheringFee;
            }
            return new FeeInfo() { SeminarFee = seminarFee, SocialGatheringFee = socialGatheringFee };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 条件から集金額を計算する
        /// </summary>
        /// <param name="id">勉強会ID</param>
        /// <param name="attendSocialGathering">懇親会参加(true/false)</param>
        /// <param name="isStudent">学生(true/false)</param>
        /// <param name="isInstructor">講師(true/false)</param>
        /// <param name="isConcerned">会場関係者(true/false)</param>
        /// <param name="isStaff">勉強会スタッフ(true/false)</param>
        /// <returns></returns>
        public FeeInfo Get(int id, bool attendSocialGathering, bool isStudent, bool isInstructor, bool isConcerned, bool isStaff)
        {
            var studyMeeting = db.StudyMeetings.Find(id);

            var participant = new Participant()
            {
                SocialGathering = attendSocialGathering,
                IsStudent = isStudent,
                IsInstructor = isInstructor,
                IsConcerned = isConcerned,
                IsStaff = isStaff
            };

            return studyMeeting.CalcFee(participant);
        }
Ejemplo n.º 3
0
            public void 懇親会に参加しない場合は参加料のみ()
            {
                var participant = new Participant()
                {
                    SocialGathering = false,
                    IsStudent = false,
                    IsInstructor = false,
                    IsConcerned = false,
                    IsStaff = false
                };

                var actual = sut.CalcFee(participant);

                Assert.AreEqual(500, actual.SeminarFee);
                Assert.AreEqual(0, actual.SocialGatheringFee);
            }
Ejemplo n.º 4
0
            public void 会場関係者は参加費無料()
            {
                var participant = new Participant()
                {
                    SocialGathering = true,
                    IsStudent = false,
                    IsInstructor = false,
                    IsConcerned = true,
                    IsStaff = false
                };

                var actual = sut.CalcFee(participant);

                Assert.AreEqual(0, actual.SeminarFee);
                Assert.AreEqual(4000, actual.SocialGatheringFee);
            }
Ejemplo n.º 5
0
        public ActionResult Add(int id, Participant participant)
        {
            StudyMeeting studyMeeting = db.StudyMeetings.Find(id);

            if (ModelState.IsValid)
            {
                studyMeeting.Participants.Add(participant);
                db.SaveChanges();
                return RedirectToAction("Add", new { Id = id });
            }

            var model = new ParticipantAddViewModel
            {
                StudyMeeting = studyMeeting,
                Participants = studyMeeting.Participants.ToList()
            };
            return View(model);
        }
Ejemplo n.º 6
0
        public IHttpActionResult PutParticipant(int id, Participant participant)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != participant.Id)
            {
                return BadRequest();
            }

            if (!db.Participants.Any(x => x.Id == id))
            {
                return NotFound();
            }

            db.Entry(participant).State = EntityState.Modified;
            db.SaveChanges();

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 7
0
 public ActionResult Edit(Participant participant, int studyMeetingId)
 {
     if (ModelState.IsValid)
     {
         db.Entry(participant).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Add", new { id = studyMeetingId });
     }
     var model = new ParticipantEditViewModel();
     model.StudyMeetingId = studyMeetingId;
     model.Participant = participant;
     return View(model);
 }
Ejemplo n.º 8
0
            public void 学生は参加費無料かつ懇親会費は学生料金()
            {
                var participant = new Participant()
                {
                    SocialGathering = true,
                    IsStudent = true,
                    IsInstructor = false,
                    IsStaff = false
                };

                var actual = sut.CalcFee(participant);

                Assert.AreEqual(0, actual.SeminarFee);
                Assert.AreEqual(3000, actual.SocialGatheringFee);
            }