public string EditWorkitem(Workitem id) { try { using (var entities = new WorkBountyDBEntities()) { var getWorkitemData = entities.Workitems.Where(x => x.WorkitemID == id.WorkitemID).ToList(); getWorkitemData.ForEach(a => { if (id.Amount != null) { a.Amount = id.Amount; } a.ModifyBy = id.ModifyBy; if (id.ModifyDateTime != null) { a.ModifyDateTime = id.ModifyDateTime; } a.PublishedTo = id.PublishedTo; if (id.Summary != null) { a.Summary = id.Summary; } if (id.Title != null) { a.Title = id.Title; } if (id.ProposedReward != "undefined") { a.ProposedReward = id.ProposedReward; } } ); WorkitemStatu workitemstatusData = new WorkitemStatu(); string statusDescription = "Update"; workitemstatusData.StatusDescription = statusDescription; workitemstatusData.WorkitemID = id.WorkitemID; entities.WorkitemStatus.Add(workitemstatusData); entities.SaveChanges(); WorkitemHistory workitemHistoryData = new WorkitemHistory(); workitemHistoryData.WorkitemID = id.WorkitemID; workitemHistoryData.UpdatedBy = id.ModifyBy; workitemHistoryData.UpdatedDateTIme = DateTime.Now; var getWorkitemStatusID = entities.WorkitemStatus.Where(s => s.WorkitemID == id.WorkitemID).Select(s => s.WorkitemStatusID).FirstOrDefault(); workitemHistoryData.WorkitemStatusID = getWorkitemStatusID; entities.WorkitemHistories.Add(workitemHistoryData); entities.SaveChanges(); } return("Success"); } catch (Exception) { return("Error"); } }
public string EditWorkitem(Workitem id) { try { using (var entities = new WorkBountyDBEntities()) { var getWorkitemData = entities.Workitems.Where(x => x.WorkitemID==id.WorkitemID).ToList(); getWorkitemData.ForEach(a => { if(id.Amount!=null) a.Amount = id.Amount; a.ModifyBy = id.ModifyBy; if (id.ModifyDateTime != null) a.ModifyDateTime = id.ModifyDateTime; a.PublishedTo = id.PublishedTo; if (id.Summary != null) a.Summary = id.Summary; if (id.Title != null) a.Title = id.Title; if (id.ProposedReward != "undefined") a.ProposedReward = id.ProposedReward; } ); WorkitemStatu workitemstatusData = new WorkitemStatu(); string statusDescription = "Update"; workitemstatusData.StatusDescription = statusDescription; workitemstatusData.WorkitemID = id.WorkitemID; entities.WorkitemStatus.Add(workitemstatusData); entities.SaveChanges(); WorkitemHistory workitemHistoryData = new WorkitemHistory(); workitemHistoryData.WorkitemID = id.WorkitemID; workitemHistoryData.UpdatedBy = id.ModifyBy; workitemHistoryData.UpdatedDateTIme = DateTime.Now; var getWorkitemStatusID = entities.WorkitemStatus.Where(s => s.WorkitemID == id.WorkitemID).Select(s => s.WorkitemStatusID).FirstOrDefault(); workitemHistoryData.WorkitemStatusID = getWorkitemStatusID; entities.WorkitemHistories.Add(workitemHistoryData); entities.SaveChanges(); } return "Success"; } catch (Exception) { return "Error"; } }