public Response Accept(int id, string message) { var accept = new MeetingAccept() { meetingId = id, acceptorId = GetUserId(), message = message }; var meetingRep = new MeetingRepository(); var meeting = meetingRep.Meetings.FirstOrDefault(x => x.Id == accept.meetingId); if (meeting == null) { return new BadRequestError("No such meeting"); } meeting.checkPermissions(GetUserId()); if (meeting.isOwner) { return new UnauthorizedError("Not for owner"); } if (meeting.IsAccepter) { return new BadRequestError("Already accepted"); } if (meeting.confirmer != null) { return new BadRequestError("Already confirmed"); } int acceptId = meetingRep.Create(accept); if (acceptId > 0) { return Response(acceptId); } return new InternalError(); }
public int Create(MeetingAccept accept) { if (accept.Id == 0) { context.MeetingAccepts.InsertOnSubmit(accept); SubmitChanges(); Service.Notify.NewAccept(accept); return accept.Id; } return -1; }
public static MeetingAcceptApiModel Map(MeetingAccept accept) { return new MeetingAcceptApiModel() { id = accept.Id.ToString(), acceptor = new UserApiModel() { id = accept.AspNetUser.Id, username = accept.AspNetUser.UserName, photo = accept.AspNetUser.photo }, confirmed = accept.confirmed, meetingId = accept.meetingId.ToString(), message = accept.message, time = accept.time }; }
public ActionResult Accept(MeetingAccept accept) { var meetingRep = new MeetingRepository(); var meeting = meetingRep.Meetings.FirstOrDefault(x => x.Id == accept.meetingId); if (meeting == null) { throw new Exception(); } if (meeting.confirmer != null) { throw new Exception(); } int id = meetingRep.Create(accept); if (id > 0) { Notify.NewAccept(accept); return View(true); } throw new Exception(); }
private void detach_MeetingAccepts(MeetingAccept entity) { this.SendPropertyChanging(); entity.Meeting = null; }
private void attach_MeetingAccepts(MeetingAccept entity) { this.SendPropertyChanging(); entity.Meeting = this; }
partial void DeleteMeetingAccept(MeetingAccept instance);
partial void UpdateMeetingAccept(MeetingAccept instance);
partial void InsertMeetingAccept(MeetingAccept instance);