public int CreateInvoice(Invoice invoice) { var res = invoicesRepository.Insert(invoice.AutoMapObject <Invoice, DB.Invoice>()); //Commencing workflow var firstWorkflowStage = workflowStagesRepository.GetAll().OrderBy(w => w.StageOrderNumber).FirstOrDefault(); if (firstWorkflowStage != null) { var workflowProcessor = new pmcs.Business.WorkflowProcessors.InvoiceWorkflowProcessor(); workflowProcessor.BeginWorkflowProcess( new Model.Contracts.InvoicesApprovalWorkflow() { InvoiceId = res.InvoiceId, IsFinished = false, ReferenceNumber = "", Status = (int)WorkflowLevelStatus.New, IsActive = true, CreatedDate = DateTime.Now, CreatedBy = 0, StageId = firstWorkflowStage.StageId, }, firstWorkflowStage.AutoMapObject <DB.InvoiceWorkflowStage, Model.InvoiceWorkflowStage>() ); } return(res.InvoiceId); }
public IEnumerable <InvoiceWorkflowStage> GetWorkflowStages() { return(workflowStagesRepository .GetAll() .Select(dbWorkflow => dbWorkflow.AutoMapObject <DB.InvoiceWorkflowStage, InvoiceWorkflowStage>()) .OrderByDescending(c => c.StageId)); }