public async Task <bool> SaveTicketStatusHistory(long workOrderId, bool isNew, long workOrderStatus, long loggedUserId) { IWorkOrderStatusHistory workOrderStatusHistory = null; workOrderStatusHistory = new WorkOrderStatusHistory(); workOrderStatusHistory.WorkOrderId = workOrderId; workOrderStatusHistory.CreatedBy = loggedUserId; workOrderStatusHistory.CreatedDate = DateTime.UtcNow; if (isNew) { workOrderStatusHistory.WorkOrderStatusId = 1; await this._workOrderStatusHistoryRepository.AddNew(workOrderStatusHistory); if (workOrderStatus == 2) { workOrderStatusHistory.WorkOrderStatusId = 2; await this._workOrderStatusHistoryRepository.AddNew(workOrderStatusHistory); } } else { workOrderStatusHistory.WorkOrderStatusId = workOrderStatus; await this._workOrderStatusHistoryRepository.AddNew(workOrderStatusHistory); } return(true); }
public ValueDataResponse <WorkOrder> CloseWorkOrder(int WorkOrderId, int StatusTypeId, string Comments) { ValueDataResponse <WorkOrder> response = new ValueDataResponse <WorkOrder>(); try { var orderData = _appContext.WorkOrders.Where(x => x.Id == WorkOrderId).FirstOrDefault(); if (orderData != null) { orderData.StatusTypeId = StatusTypeId; WorkOrderStatusHistory request = new WorkOrderStatusHistory() { WorkOrderId = orderData.Id, StatusTypeId = StatusTypeId, Comments = Comments, CreatedBy = orderData.CreatedBy, UpdatedBy = orderData.UpdatedBy, CreatedDate = orderData.CreatedDate, UpdatedDate = DateTime.Now, }; _appContext.WorkOrderStatusHistories.Add(request); _appContext.SaveChanges(); response.Result = orderData; response.IsSuccess = true; response.AffectedRecords = 1; response.EndUserMessage = "Work Order Accepted Successfully"; } else { response.IsSuccess = true; response.AffectedRecords = 0; response.EndUserMessage = "No Work Order Found"; } } catch (Exception ex) { response.IsSuccess = false; response.AffectedRecords = 0; response.EndUserMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message; response.Exception = ex; } return(response); }