public IHttpActionResult GetNext(int id, bool cancel = false) { try { InvoiceHelper helper = new InvoiceHelper(); Invoice entity = helper.NextStep(UnitOfWork, id, cancel); return(Ok(Factory.Create(entity))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult GetNext(int id, bool cancel = false) { try { int agentId = UnitOfWork.Invoices.Get(id).Agent.Id; if (Identity.HasNotAccess(agentId)) { return(Unauthorized()); } InvoiceHelper helper = new InvoiceHelper(); Invoice entity = helper.NextStep(UnitOfWork, id, cancel); return(Ok(Factory.Create(entity))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private List <string> Update(int productId) { InvoiceHelper states = new InvoiceHelper(); List <string> invoices = new List <string>(); var items = UnitOfWork.AutomaticStates.Get().Where(x => (x.Completed == false)).ToList() .Where(x => x.Invoice.Items.Where(y => productId == y.Product.Id).ToList().Count > 0) .ToList(); foreach (var item in items) { try { while (item.Invoice.Status != Status.InvoiceShipped) { states.NextStep(UnitOfWork, item.Invoice.Id, false); } } catch (Exception ex) { Logger.Log(ex.Message, "INFO"); } } return(invoices); }