public bool AddDiscussions(BOTS_TblDiscussion objDiscussion) { bool status = false; BOTS_TblSubDiscussionData objsubdiscussion = new BOTS_TblSubDiscussionData(); try { using (var context = new CommonDBContext()) { context.BOTS_TblDiscussion.AddOrUpdate(objDiscussion); context.SaveChanges(); if (objDiscussion.Status == "WIP") { objsubdiscussion.DiscussionId = objDiscussion.Id; objsubdiscussion.GroupId = objDiscussion.GroupId; objsubdiscussion.FollowupDate = objDiscussion.FollowupDate; objsubdiscussion.Description = objDiscussion.Description; objsubdiscussion.Status = objDiscussion.Status; objsubdiscussion.UpdatedBy = objDiscussion.AddedBy; context.BOTS_TblSubDiscussionData.AddOrUpdate(objsubdiscussion); context.SaveChanges(); } status = true; } } catch (Exception ex) { newexception.AddException(ex, objDiscussion.GroupId); } return(status); }
public bool UpdateDiscussions(string id, string Desc, string Status, string LoginId) { BOTS_TblDiscussion objDiscussion = new BOTS_TblDiscussion(); BOTS_TblSubDiscussionData objsubdiscussion = new BOTS_TblSubDiscussionData(); bool status = false; try { using (var context = new CommonDBContext()) { int discussionId = Convert.ToInt32(id); objDiscussion = context.BOTS_TblDiscussion.Where(x => x.Id == discussionId).FirstOrDefault(); objDiscussion.UpdatedDate = DateTime.Now; objDiscussion.Status = Status; context.BOTS_TblDiscussion.AddOrUpdate(objDiscussion); context.SaveChanges(); objsubdiscussion.DiscussionId = objDiscussion.Id; objsubdiscussion.GroupId = objDiscussion.GroupId; objsubdiscussion.FollowupDate = objDiscussion.FollowupDate; objsubdiscussion.Description = Desc; objsubdiscussion.Status = objDiscussion.Status; objsubdiscussion.UpdatedBy = LoginId; objsubdiscussion.AddedDate = DateTime.Now; context.BOTS_TblSubDiscussionData.AddOrUpdate(objsubdiscussion); context.SaveChanges(); status = true; } } catch (Exception ex) { newexception.AddException(ex, objDiscussion.GroupId); } return(status); }