public ConfirmationResponse Execute(CreateMeetingRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var projectExists = _projectRepository.Exists(request.ProjectId);

            if (!projectExists)
            {
                throw new UseCaseException("Project doesn't exist.");
            }

            var personsExist = request.InvolvedPersons.Concat(new [] { request.OrganizedBy }).All(x => _personRepository.Exists(x));

            if (!personsExist)
            {
                throw new UseCaseException("One or more users don't exist.");
            }

            var entity = ToDomainEntity(request);
            var result = _meetingRepository.Create(entity);

            return(new ConfirmationResponse("Meeting created successfully.")
            {
                Id = result,
            });
        }
        public async Task <IOperationResult <Meeting> > CreateMeeting(Meeting meeting)
        {
            if (meeting == null)
            {
                return(BasicOperationResult <Meeting> .Fail("El objeto que envió es inválido"));
            }

            var validation = await ValidateMeeting(meeting);

            if (!validation.Success)
            {
                return(validation);
            }

            meeting.Status = MeetingStatus.Pending;

            _meetingRepository.Create(meeting);

            await _meetingRepository.Save();

            var response = await _meetingRepository.Find(m => m.Id == meeting.Id, m => m.Subject, m => m.Tutor, m => m.Student);

            await _notificationManager.NotifyStudentMeetingWasCreated(meeting.StudentId, meeting.Subject.Name, meeting.Tutor.FullName);

            await _notificationManager.NotifyParentsOfMeetingCreatedForStudent(meeting);

            return(BasicOperationResult <Meeting> .Ok(response));
        }
Exemple #3
0
        public async Task <IActionResult> SelectMeetingDate(int?id, string user, MeetingDateViewModel meetingDate)
        {
            if (id == null || user == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                var claim = await claimRepository.GetFoundItemClaimById(id);

                if (user != claim.ApplicationUserId)
                {
                    return(View());
                }
                var meeting = new Meeting {
                    FoundItem = claim.FoundItem, UserSelectedDate = (DateTime)meetingDate.FirstDate, USerSelectedDate2 = (DateTime)meetingDate.SecondDate, LocalGovernmentId = meetingDate.LGAId
                };
                meetingRepository.Create(meeting);
                meetingRepository.Save();
                var firstdate  = ((DateTime)meetingDate.FirstDate).ToShortDateString();
                var seconddate = ((DateTime)meetingDate.SecondDate).ToShortDateString();
                var link       = Url.Action("ConfirmDate", "Meeting", new { area = "User", id = claim.Id, firstDate = firstdate, secondDate = seconddate }, Request.Scheme);
                await System.IO.File.WriteAllTextAsync("ConfirmDate.txt", link);

                var message = new Dictionary <string, string>
                {
                    { "FName", " User" },
                    { "EmailClaimLink", link }
                };
                await emailNotifier.SendEmailAsync(claim.ApplicationUser.Email, "Meeting Arrangement", message, "SetUpMeeting");

                return(RedirectToAction("Success", "Account"));
            }
            return(RedirectToAction("SelectMeetingDate"));
        }
Exemple #4
0
 public IActionResult Create([FromBody] CreateMeetingForm meetingForm)
 {
     if (ModelState.IsValid)
     {
         //Todo : Add userS in the creation of a meeting.
         _repository.Create(new Meeting(meetingForm.MeetingDateTime, meetingForm.MeetingPlace));
         return(Ok());
     }
     return(BadRequest());
 }
        //public void Create(Meeting entity, int userId)
        //{
        //    _repository.Create(entity.ToGlobal(), userId);
        //}

        public void Create(Meeting entity)
        {
            _repository.Create(entity.ToGlobal());
        }