public SageResponse <SageWorkOrder> UnassignWorkOrders(string id) { try { if (id == string.Empty) { throw new ResponseException(new ResponseError() { Message = "WorkOrder id is empty" }); } this.serviceOdbc.UnassignWorkOrder(id); var result = new SageResponse <SageWorkOrder> { IsSucceed = true }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrder> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageNote> GetWorkOrderNotes(string id) { try { if (string.IsNullOrEmpty(id)) { return(new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = "WorkOrder Id is null or empty." }); } var result = new SageResponse <SageNote> { IsSucceed = true, Entities = serviceOdbc.GetNotes(id) }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageNote> DeleteWorkOrderNote(string id) { try { if (string.IsNullOrEmpty(id)) { return(new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = "Note Id is null or empty." }); } serviceOdbc.DeleteNote(id); var result = new SageResponse <SageNote> { IsSucceed = true }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageAssignment> GetAssignment(string id) { try { if (id == string.Empty || id == null) { return(new SageResponse <SageAssignment> { IsSucceed = false, ErrorMassage = "Assignment Id is null or empty." }); } var assignments = this.serviceManager.Assignments(id); var result = new SageResponse <SageAssignment> { IsSucceed = true, Entity = assignments == null ? null : assignments.FirstOrDefault() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageAssignment> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrderItem> GetEquipmentsByWorkOrderId(string id) { try { if (id == string.Empty || id == null) { return(new SageResponse <SageWorkOrderItem> { IsSucceed = false, ErrorMassage = "WorkOrder Id is null or empty." }); } var result = new SageResponse <SageWorkOrderItem> { IsSucceed = true, Entities = serviceManager.GetEquipmentsByWorkOrderId(id)?.ToList() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrder> AddWorkOrder(SageWorkOrder workOrder) { try { var properties = new Dictionary <string, string>(); properties.Add("ARCustomer", workOrder.ARCustomer ?? string.Empty); properties.Add("Location", workOrder.Location ?? string.Empty); properties.Add("CallType", workOrder.CallType ?? string.Empty); properties.Add("CallDate", workOrder.CallDate.ToString() ?? string.Empty); properties.Add("Problem", workOrder.Problem ?? string.Empty); properties.Add("RateSheet", workOrder.RateSheet ?? string.Empty); properties.Add("Employee", workOrder.Employee ?? string.Empty); properties.Add("Equipment", workOrder.Equipment.ToString() ?? string.Empty); properties.Add("EstimatedRepairHours", workOrder.EstimatedRepairHours.ToString() ?? string.Empty); properties.Add("NottoExceed", workOrder.NottoExceed ?? string.Empty); properties.Add("Comments", workOrder.Comments ?? string.Empty); properties.Add("CustomerPO", workOrder.CustomerPO ?? string.Empty); properties.Add("Contact", workOrder.Contact ?? string.Empty); properties.Add("PermissionCode", workOrder.PermissionCode ?? string.Empty); properties.Add("PayMethod", workOrder.PayMethod ?? string.Empty); properties.Add("JCJob", workOrder.JCJob ?? string.Empty); var resultProperties = new Dictionary <string, string>(); foreach (var property in properties) { if (!string.IsNullOrEmpty(property.Value)) { resultProperties.Add(property.Key, property.Value.Sanitize()); } } var resultWorkOrder = this.serviceManager.WorkOrders(resultProperties).SingleOrDefault(); var resultAssignment = new SageAssignment(); if (resultWorkOrder != null) { resultAssignment = this.serviceManager.GetAssignmentByWorkOrderId(resultWorkOrder.WorkOrder.ToString()).SingleOrDefault(); } var result = new SageResponse <SageWorkOrder> { IsSucceed = true, Entity = resultWorkOrder, RelatedAssignment = resultAssignment }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrder> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageEquipment> GetEquipment() { try { var result = new SageResponse <SageEquipment> { IsSucceed = true, Entities = this.serviceManager.Equipments().ToList() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageEquipment> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageRateSheet> GetRateSheets() { try { var result = new SageResponse <SageRateSheet> { IsSucceed = true, Entities = this.serviceOdbc.RateSheets() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageRateSheet> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrderItem> EditEquipment(SageWorkOrderItem workOrderItem) { try { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = true, Entity = serviceManager.EditWorkOrderItem(workOrderItem).Single() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrderItem> GetWorkOrderItems() { try { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = true, Entities = this.serviceManager.WorkOrderItems().ToList() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SagePermissionCode> GetPermissionCodes() { try { var result = new SageResponse <SagePermissionCode> { IsSucceed = true, Entities = this.serviceOdbc.PermissionCodes() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SagePermissionCode> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageNote> DeleteWorkOrderNotes(IEnumerable <long> ids) { try { this.serviceOdbc.DeleteNotes(ids); var result = new SageResponse <SageNote> { IsSucceed = true }; return(result); } catch (Exception exception) { var result = new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = exception.Message }; return(result); } }
public SageResponse <SageWorkOrderItem> DeleteWorkOrderItems(int workOrderId, IEnumerable <int> ids) { try { serviceOdbc.DeleteWorkOrderItems(workOrderId, ids); var result = new SageResponse <SageWorkOrderItem> { IsSucceed = true }; return(result); } catch (Exception exception) { var result = new SageResponse <SageWorkOrderItem> { IsSucceed = false, ErrorMassage = exception.Message }; return(result); } }
public SageResponse <SageWorkOrderLocationAccordance> GetAccordance() { try { var result = new SageResponse <SageWorkOrderLocationAccordance> { IsSucceed = true, Entities = serviceOdbc.GetWorkOrderLocationAccordance().ToList() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrderLocationAccordance> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrder> EditWorkOrderStatus(string id, string status) { try { serviceOdbc.EditWorkOrderStatus(id, status); var result = new SageResponse <SageWorkOrder> { IsSucceed = true }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrder> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrder> GetWorkorders(string id) { try { var result = new SageResponse <SageWorkOrder> { IsSucceed = true, Entity = this.serviceManager.WorkOrders(id).SingleOrDefault() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrder> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageNote> CreateWorkOrderNote(SageNote note) { try { serviceOdbc.AddNote(note); var result = new SageResponse <SageNote> { IsSucceed = true }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageNote> GetWorkOrderNotes() { try { var result = new SageResponse <SageNote> { IsSucceed = true, Entities = serviceOdbc.GetNotes() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageNote> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageWorkOrder> EditWorkOrder(SageWorkOrder workOrder) { try { serviceOdbc.EditWorkOrder(workOrder); var result = new SageResponse <SageWorkOrder> { IsSucceed = true, Entity = serviceManager.WorkOrders(workOrder.WorkOrder.ToString()).SingleOrDefault() }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageWorkOrder> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }
public SageResponse <SageAssignment> AddAssignment(SageAssignment assignment) { try { var properties = new Dictionary <string, string>(); properties.Add("Assignment", assignment.Assignment.ToString()); properties.Add("ScheduleDate", ((DateTime)assignment.ScheduleDate).ToString() ?? string.Empty); properties.Add("Employee", assignment.Employee ?? string.Empty); properties.Add("WorkOrder", assignment.WorkOrder.ToString()); properties.Add("EstimatedRepairHours", assignment.EstimatedRepairHours ?? string.Empty); properties.Add("StartTime", ((DateTime)assignment.StartTime).TimeOfDay.ToString() ?? string.Empty); properties.Add("Enddate", assignment.Enddate.ToString() ?? string.Empty); properties.Add("Endtime", ((DateTime)assignment.Endtime).TimeOfDay.ToString() ?? string.Empty); var resultProperties = new Dictionary <string, string>(); foreach (var property in properties) { if (property.Value != string.Empty && property.Value != null) { resultProperties.Add(property.Key, property.Value); } } var resultAssignment = this.serviceManager.AddAssignments(resultProperties).SingleOrDefault(); var result = new SageResponse <SageAssignment> { IsSucceed = true, Entity = resultAssignment }; return(result); } catch (ResponseException exception) { var result = new SageResponse <SageAssignment> { IsSucceed = false, ErrorMassage = exception.Error.Message }; return(result); } }