public async Task <IActionResult> LikeUser(int id, int recipientId) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var like = await _repo.GetLike(id, recipientId); if (like != null) { return(BadRequest("You already like this user")); } if (await _repo.GetUser(recipientId, false) == null) { return(NotFound()); } like = new Like { LikerId = id, LikeeId = recipientId }; _repo.Add <Like>(like); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to like user")); }
public async Task <IActionResult> JoinMeeting(string mediaRegion, string meetingTitle, string attendeeName) { MeetingDto meetingResponse; // to do remove this later, for now save meetingId in session so it won't create a meeting every time an attendee joins an existing meeting if (!Guid.TryParse(meetingTitle, out var newGuid)) { var reqMeetingBody = new { ClientRequestToken = Guid.NewGuid(), MediaRegion = mediaRegion }; meetingResponse = await _chimeRepo.CreateMeeting(reqMeetingBody); } else { meetingResponse = await _chimeRepo.GetMeeting(newGuid.ToString()); } var reqAttendeeBody = new { ExternalUserId = Guid.NewGuid() }; var attendeeResponse = await _chimeRepo.CreateAttendee(reqAttendeeBody, meetingResponse.Meeting.MeetingId); var attendee = new Value(); attendee.AttendeeId = new Guid(attendeeResponse.Attendee.AttendeeId); attendee.Name = attendeeName; _meetingRepo.Add(attendee); await _meetingRepo.SaveAll(); return(Ok(new { JoinInfo = new JoinInfo() { Meeting = meetingResponse.Meeting, Attendee = attendeeResponse.Attendee, Title = meetingTitle } })); }
public async Task <IActionResult> CreateMessage(int userId, MessageForCreationDto messageForCreationDto) { var sender = await _repo.GetUser(userId); if (sender.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } messageForCreationDto.SenderId = userId; var recipient = await _repo.GetUser(messageForCreationDto.RecipientId); if (recipient == null) { return(BadRequest("Could not find user")); } var message = _mapper.Map <Message>(messageForCreationDto); _repo.Add(message); if (await _repo.SaveAll()) { var messageToReturn = _mapper.Map <MessageToReturnDto>(message); return(CreatedAtRoute("GetMessage", new { userId, id = message.Id }, messageToReturn)); } throw new Exception("Creating the message failed on save"); }
private Meeting CreateMeeting() { var meeting = new Meeting(); _meetingRepository.Add(meeting); return(meeting); }
private Meeting CreateNewMeeting() { var newMeeting = new Meeting(); _repository.Add(newMeeting); return(newMeeting); }
private Meeting CreateNewMeeting() { var meeting = new Meeting { DateFrom = DateTime.Now.Date, DateTo = DateTime.Now.Date }; _meetingRepository.Add(meeting); return(meeting); }
public void HandleMeetingAdd(Meeting meeting, int projectId, int?taskId, string userId) { meeting.ProjectID = projectId; meeting.TaskID = taskId; MeetingRepository.Add(meeting); MeetingParticipants participant = new MeetingParticipants(); participant.MeetingID = meeting.ID; participant.UserID = userId; MeetingParticipantsRepository.Add(participant); }
public async Task <IActionResult> AddMeeting(MeetingCreateDto meetingCreateDto) { Meeting meetingToCreate = _mapper.Map <Meeting>(meetingCreateDto); _repo.Add(meetingToCreate); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception($"Creating meeting failed on save"); }
public int Add(Meeting meeting) { try { meeting.Location = _meetingLocationRepository.GetByName(meeting.Location.Name); } catch (Exception e) { meeting.Location.Id = _meetingLocationRepository.Add(meeting.Location); } return(_meetingRepository.Add(meeting)); }
public async Task Add(Meeting entity) { if (!ExecutarValidacao(new MeetingValidation(), entity)) { return; } //Valid if the exists the same email in this day var any = (await _meeting.GetAll(a => a.Email == entity.Email && a.Data.ToSql() == DateTime.Now.ToSql())).Any(); if (any) { Notificar("This Email is already registered"); } await _meeting.Add(entity); }
public async Task <ActionResult <MeetingViewModel> > PostMeeting(MeetingRequestViewModel model) { var meeting = new Meeting { Date = model.Date, Name = model.Name, Note = model.Note, Cancelled = model.Cancelled }; _meetingRepository.Add(meeting); await _meetingRepository.CompleteAsync(); var attendees = await _attendeeRepository.GetAllWithRolesByMeetingAsync(meeting.Id); var reponse = ViewModelHelper.Convert(meeting, attendees); return(CreatedAtAction("GetMeeting", new { meetingId = meeting.Id }, reponse)); }
public bool AddMeeting(MeetingModel model) { try { var meeting = Mapper.Map <Meeting>(model); meeting.Id = Guid.NewGuid(); meeting.UserInMeetings.Add(new UserInMeeting { UserId = meeting.MeetingHostId }); _meetingRepository.Add(meeting); _unitOfWork.Save(); return(true); } catch (Exception) { // TODO: error handling return(false); } }
public ActionResult Create(Meeting meeting) { if (ModelState.IsValid) { try { //Take tne new meeting which has been posted and save it. meetingRepository.Add(meeting); return(RedirectToAction("Index")); } catch { //If there is an exception return the form view. return(View(meeting)); } } else { //If there is a validation error return the form view. return(View(meeting)); } }
public void Add(Meeting obj) { _repository.Add(obj); }
public Meeting Post([FromBody] Meeting entity) { return(_meetingRepository.Add(entity)); }