public static MeetingMember ConvertToMeetingMembers(this MM_MeetingMember meetingMemberDbModel) { return(new MeetingMember() { Id = meetingMemberDbModel.Id, MemberAs = (MeetingMemberType)meetingMemberDbModel.MemberAs, Member = meetingMemberDbModel.MM_User.ConvertToUser(), IsAttend = meetingMemberDbModel.IsAttend }); }
public MeetingMember GetById(int id) { MM_MeetingMember meetingMemberDbModel = _meetingDbContext.MM_MeetingMembers.FirstOrDefault(r => r.Id == id); if (meetingMemberDbModel == null) { throw new EntityNotFoundException <MeetingMember>(id); } Console.WriteLine("Log Event got by id."); return(meetingMemberDbModel.ConvertToMeetingMembers()); }
public void Update(Meeting meeting) { MM_Meeting meetingDbModel = _meetingDbContext.MM_Meetings.Find(meeting.Id); if (meetingDbModel == null) { throw new EntityNotFoundException <Meeting>((int)meeting.Id); } meetingDbModel.MeetingStatus = (int)meeting.StatusType; if (meeting.StatusType == MeetingStatusType.Ended) { meetingDbModel.EndDateTime = DateTime.UtcNow; } else { meetingDbModel.EndDateTime = null; meetingDbModel.MeetingLocationId = meeting.Location.Id; meetingDbModel.MeetingStatus = (int)meeting.StatusType; meetingDbModel.StartDateTime = meeting.StartDate;// meeting.StartDate; //meetingDbModel.EndDateTime = meeting.EndDate;//meeting.EndDate; meetingDbModel.Subject = meeting.Subject; IList <MM_MeetingMember> meetingMembers = meetingDbModel.MM_MeetingMember.Select(x => x).ToList(); //Add meeting members. foreach (MeetingMember member in meeting.Members) { MM_MeetingMember meetingMemberDbModel = new MM_MeetingMember() { UserId = member.Id, MemberAs = (int)member.MemberAs }; meetingDbModel.MM_MeetingMember.Add(meetingMemberDbModel); } } try { _meetingDbContext.SaveChanges(); } catch (Exception ex) { throw new UpdateFailedException <Meeting>((int)meeting.Id); } Console.WriteLine("Log Event is Updated."); }
public void Delete(int id) { MM_MeetingMember meetingMemberDbModel = _meetingDbContext.MM_MeetingMembers.FirstOrDefault(x => x.Id == id); if (meetingMemberDbModel == null) { throw new EntityNotFoundException <MeetingMember>(id); } _meetingDbContext.MM_MeetingMembers.Remove(meetingMemberDbModel); try { _meetingDbContext.SaveChanges(); } catch (Exception ex) { throw new DeleteFailedException <MeetingMember>(id); } Console.WriteLine("Log Event is Deleted."); }
public void Update(MeetingMember meetingMember) { MM_MeetingMember meetingMemberDbModel = _meetingDbContext.MM_MeetingMembers.Find(meetingMember.Id); if (meetingMemberDbModel == null) { throw new EntityNotFoundException <MeetingMember>(meetingMember.Id); } //meetingMemberDbModel.MeetingId = meetingMember.Meeting.Id; //meetingMemberDbModel.UserId = meetingMember.Member.Id; //meetingMemberDbModel.MemberAs = (int)meetingMember.MemberAs; meetingMemberDbModel.IsAttend = meetingMember.IsAttend; meetingMemberDbModel.MemberAs = (int)meetingMember.MemberAs; try { _meetingDbContext.SaveChanges(); } catch (Exception ex) { throw new UpdateFailedException <MeetingMember>(meetingMember.Id); } Console.WriteLine("Log Event is Updated."); }
public int Add(MeetingMember meetingMember) { MM_MeetingMember meetingMemberDbModel = new MM_MeetingMember() { MeetingId = meetingMember.Meeting.Id, UserId = meetingMember.Member.Id, MemberAs = (int)meetingMember.MemberAs }; _meetingDbContext.MM_MeetingMembers.Add(meetingMemberDbModel); try { _meetingDbContext.SaveChanges(); } catch (Exception ex) { throw new AddFailedException <MeetingMember>(); } Console.WriteLine("Log Item is Added."); return(meetingMemberDbModel.Id); }
public int Add(Meeting meeting) { MM_Meeting meetingDbModel = new MM_Meeting() { CreatedDate = DateTime.UtcNow, CreatedUserId = meeting.CreatedUser.Id, MeetingLocationId = meeting.Location.Id, MeetingStatus = (int)meeting.StatusType, StartDateTime = meeting.StartDate, //meeting.StartDate, EndDateTime = null, //meeting.EndDate,//DateTime.UtcNow,//meeting.EndDate, Subject = meeting.Subject, ParentMeetingId = meeting.ParentMeeting == null ? (int?)null : meeting.ParentMeeting.Id }; _meetingDbContext.MM_Meetings.Add(meetingDbModel); foreach (MeetingMember memberMember in meeting.Members) { MM_MeetingMember meetingMemberDbModel = new MM_MeetingMember() { UserId = memberMember.Id, MemberAs = (int)memberMember.MemberAs }; meetingDbModel.MM_MeetingMember.Add(meetingMemberDbModel); } foreach (Agenda title in meeting.Titles) { int parentOrderId = 0; if (title.Heading == null) { MM_Agenda agenda = new MM_Agenda() { Title = title.Title, SerialId = title.SerialId, OrderId = title.OrderId, }; int childOrderId = 0; foreach (Agenda subtitle in title.SubTitles) { MM_Agenda subTitle = new MM_Agenda() { Title = subtitle.Title, SerialId = subtitle.SerialId, OrderId = subtitle.OrderId, }; agenda.MM_Agenda1.Add(subTitle); } meetingDbModel.MM_Agenda.Add(agenda); } } try { _meetingDbContext.SaveChanges(); } catch (Exception ex) { throw new AddFailedException <Meeting>(); } Console.WriteLine("Log Item is Added."); return(meetingDbModel.Id); }