public static bool Validate(IUnitOfWork db, BuyerBlackListViewModel model, out IList <KeyValuePair <string, string> > errors) { errors = new List <KeyValuePair <string, string> >(); var order = db.Orders.UniversalGetByOrderId(model.OrderId); if (order == null) { errors.Add(new KeyValuePair <string, string>("FromOrderId", "Not found")); } return(!errors.Any()); }
public static BuyerBlackListViewModel Add(IUnitOfWork db, BuyerBlackListViewModel item, DateTime?when, long?by) { var itemDb = new BuyerBlackList { OrderId = item.OrderId, Reason = item.Reason, CreateDate = when, CreatedBy = by }; db.BuyerBlackLists.Add(itemDb); db.Commit(); item = new BuyerBlackListViewModel(db.BuyerBlackLists.GetExtendedByIdAsDto(itemDb.Id)); //item.Id = itemDb.Id; return(item); }
public static BuyerBlackListViewModel Update(IUnitOfWork db, BuyerBlackListViewModel item, DateTime?when, long?by) { if (!item.Id.HasValue) { return(null); } var itemDb = db.BuyerBlackLists.Get(item.Id.Value); if (itemDb != null) { itemDb.OrderId = item.OrderId; itemDb.Reason = item.Reason; itemDb.UpdateDate = when; itemDb.UpdatedBy = by; db.Commit(); return(new BuyerBlackListViewModel(db.BuyerBlackLists.GetExtendedByIdAsDto(itemDb.Id))); } return(null); }