public int SaveMeetingRoom(Model.MeetingRoom meetingRoom) { DataAccess.Mapping.MeetingRoom mr = null; bool find = false; if (meetingRoom.MeetingRoomID == -1) { mr = new Mapping.MeetingRoom(); dc.MeetingRoom.InsertOnSubmit(mr); find = true; } else { mr = (from meeting in dc.MeetingRoom where meeting.MeetingRoomID == meetingRoom.MeetingRoomID select meeting).FirstOrDefault(); if (mr != null) { find = true; mr.MeetingRoomID = meetingRoom.MeetingRoomID; } } if (find) { mr.MeetingRoomCapacity = meetingRoom.MeetingRoomCapacity; mr.MeetingRoomName = meetingRoom.MeetingRoomName; mr.MeetingRoomStatus = meetingRoom.MeetingRoomStatus; mr.MeetingTypeID = meetingRoom.MeetingTypeID; try { dc.SubmitChanges(); } catch (ChangeConflictException) { dc.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues); dc.SubmitChanges(); } return(mr.MeetingRoomID); } else { return(-1); } }
public int SaveMeetingRoom(Model.MeetingRoom meetingRoom) { DataAccess.Mapping.MeetingRoom mr = null; bool find = false; if (meetingRoom.MeetingRoomID == -1) { mr = new Mapping.MeetingRoom(); dc.MeetingRoom.InsertOnSubmit(mr); find = true; } else { mr = (from meeting in dc.MeetingRoom where meeting.MeetingRoomID == meetingRoom.MeetingRoomID select meeting).FirstOrDefault(); if (mr != null) { find = true; mr.MeetingRoomID = meetingRoom.MeetingRoomID; } } if (find) { mr.MeetingRoomCapacity = meetingRoom.MeetingRoomCapacity; mr.MeetingRoomName = meetingRoom.MeetingRoomName; mr.MeetingRoomStatus = meetingRoom.MeetingRoomStatus; mr.MeetingTypeID = meetingRoom.MeetingTypeID; try { dc.SubmitChanges(); } catch (ChangeConflictException) { dc.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues); dc.SubmitChanges(); } return mr.MeetingRoomID; } else { return -1; } }