public IUnitOfWorkResult OrderCancel(int orderId, GlobalEnumerator.OrderStatus status) { var repo = RepoGeneric; var order = repo.FindOne<Order>(c => c.OrderId == orderId); if (order == null) return this.CreateResultError(string.Format("Order with id = {0} not found", orderId)); order.Status = (int)status; switch (status) { case GlobalEnumerator.OrderStatus.Canceled_by_client: order.CanceledBy = (int)GlobalEnumerator.OrderCanceledBy.Client; break; case GlobalEnumerator.OrderStatus.Canceled_by_system: order.CanceledBy = (int)GlobalEnumerator.OrderCanceledBy.System; break; case GlobalEnumerator.OrderStatus.Canceled_by_taxi: order.CanceledBy = (int)GlobalEnumerator.OrderCanceledBy.Taxi; break; } order.TimeCanceled = DateTime.Now; order.CancelCause = 0; return repo.UnitOfWork.SaveChanges(); }
public IUnitOfWorkResult OrderProcess(int orderId, GlobalEnumerator.OrderStatus status, int? assignedCarId = null, double? finalPrice = null, string comment = null) { var repo = RepoGeneric; var order = repo.FindOne<Order>(c => c.OrderId == orderId); if (order == null) return this.CreateResultError(string.Format("Order with id = {0} not found", orderId)); order.Status = (int)status; switch (status) { case GlobalEnumerator.OrderStatus.Assigned: order.TimeAssigned = DateTime.Now; if (assignedCarId.HasValue) order.CarId = assignedCarId.Value; else return this.CreateResultError("AssignedCarId can't be null!"); break; case GlobalEnumerator.OrderStatus.Arrived: order.TimeArrived = DateTime.Now; break; case GlobalEnumerator.OrderStatus.Incar: order.TimeInCar = DateTime.Now; break; case GlobalEnumerator.OrderStatus.Done: order.TimeDone = DateTime.Now; if (finalPrice.HasValue) order.FinalPrice = finalPrice.Value; break; } if (!string.IsNullOrEmpty(comment)) order.TaxiComment = comment; return repo.UnitOfWork.SaveChanges(); }
public IUnitOfWorkResult OrderNote(int orderId, GlobalEnumerator.OrderNoteType type, int? vote = null, string comment = null) { var repo = RepoGeneric; var order = repo.FindOne<Order>(c => c.OrderId == orderId); if (order == null) return this.CreateResultError(string.Format("Order with id = {0} not found", orderId)); var orderNote = new OrderNote(); orderNote.NoteType = (int)type; switch (type) { //TODO Obsluzyc zmiane rankingu firmy uwzgledniajac ten glos case GlobalEnumerator.OrderNoteType.Feedback: orderNote.Vote = vote.GetValueOrDefault(); break; } if (!string.IsNullOrEmpty(comment)) orderNote.UserComment = comment; orderNote.CreationTime = DateTime.Now; repo.Add<OrderNote>(orderNote); return repo.UnitOfWork.SaveChanges(); }