public async Task <IWorkOrderStatusHistory> AddNew(IWorkOrderStatusHistory entity) { TWorkOrderStatusHistory tEntity = entity as TWorkOrderStatusHistory; var errors = await this.ValidateEntityToAdd(tEntity); if (errors.Count() > 0) { await this.ThrowEntityException(errors); } try { this.StartTransaction(); var savedEntity = await base.AddNew(entity as TWorkOrderStatusHistory); this.CommitTransaction(); return(savedEntity); } catch (PostgresException ex) { throw new EntityUpdateException(ex); } catch { throw; } }
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); }