public HttpResponseMessage DeleteWorkitem(WorkItem item) { try { DBWorkItem.DeleteFromDMS(item); } catch (Exception e) { Logger.ErrorLog(e.Message); // TODO: throw proper exceptions. throw e; } return Request.CreateResponse(HttpStatusCode.OK); }
public HttpResponseMessage PutWorkItem(WorkItem item) { try { DBWorkItem.UpdateToDMS(item); } catch (Exception e) { Logger.ErrorLog(e.Message); throw e; } return Request.CreateResponse(HttpStatusCode.Created); }
private bool DeleteWorkItemData(WorkItem item) { bool isDeleted = false; try { if (item != null && item.ID > 0) { WorkItem tempItem = dmsContext.WorkItems.First(i => i.ID == item.ID); if (tempItem != null) { dmsContext.DeleteObject(tempItem); dmsContext.SaveChanges(); isDeleted = true; } else { return false; } } else { throw new ArgumentException(); } } catch (Exception e) { Logger.ErrorLog(e.Message); // TODO: Add custom Exceptions/ Logs } return isDeleted; }
private bool UpdateWorkItemData(WorkItem item) { bool isUpdated = false; try { if (item != null && item.ID > 0) { WorkItem tempItem = dmsContext.WorkItems.First(i => i.ID == item.ID); if (tempItem != null) { // TODO : Write Custom SP's for each DB operation and call corresponding methods here dmsContext.SaveChanges(); isUpdated = true; } else { isUpdated = false; } } else { throw new ArgumentException(); } } catch (Exception e) { Logger.ErrorLog(e.Message); // TODO: Add custom Exceptions/ Logs } return isUpdated; }
/// <summary> /// Method to delete Workitems from DMS /// </summary> /// <param name="item"></param> public void DeleteFromDMS(WorkItem item) { this.DeleteWorkItemData(item); }
/// <summary> /// Method to update Workitems to DMS /// </summary> /// <param name="item"></param> public void UpdateToDMS(WorkItem item) { this.UpdateWorkItemData(item); }
/// <summary> /// Method to Insert Workitems data to DMS /// </summary> /// <param name="item"></param> public void InsertToDMS(WorkItem item) { try { dmsContext.AddToWorkItems(item); dmsContext.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); } catch (Exception e) { Logger.ErrorLog(e.Message); } }
/// <summary> /// Method to read Work item from DMS /// </summary> /// <param name="item"></param> /// <returns></returns> public WorkItemDTO ReadFromDMS(WorkItem item) { WorkItemDTO tempItem = null; try { tempItem = MapWorkItemsDTO().First(u => u.ID == item.ID); } catch (Exception e) { Logger.ErrorLog(e.Message); throw e; } return tempItem; }
// GET api/WorkItem/5 public WorkItemDTO GetWorkItem(WorkItem item) { return DBWorkItem.ReadFromDMS(item); }
/// <summary> /// Create a new WorkItem object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="type">Initial value of the Type property.</param> /// <param name="status">Initial value of the Status property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="priority">Initial value of the Priority property.</param> /// <param name="severity">Initial value of the Severity property.</param> /// <param name="assignTo">Initial value of the AssignTo property.</param> /// <param name="openedBy">Initial value of the OpenedBy property.</param> /// <param name="areaPath">Initial value of the AreaPath property.</param> public static WorkItem CreateWorkItem(global::System.Int32 id, global::System.Int32 type, global::System.Int32 status, global::System.String title, global::System.Int32 priority, global::System.Int32 severity, global::System.Int32 assignTo, global::System.Int32 openedBy, global::System.String areaPath) { WorkItem workItem = new WorkItem(); workItem.ID = id; workItem.Type = type; workItem.Status = status; workItem.Title = title; workItem.Priority = priority; workItem.Severity = severity; workItem.AssignTo = assignTo; workItem.OpenedBy = openedBy; workItem.AreaPath = areaPath; return workItem; }
/// <summary> /// Deprecated Method for adding a new object to the WorkItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWorkItems(WorkItem workItem) { base.AddObject("WorkItems", workItem); }