public static int CheckBuy(int id) { Buy buy = BuySvc.RetrieveById(id)[0]; Good good = GoodSvc.RetrieveById(buy.GoodId)[0]; Person person = PersonSvc.RetrieveById(buy.PersonId)[0]; if (buy.IsCheck == false) { if (good.Num < buy.Num) { return(-1); } good.Num -= buy.Num; GoodSvc.Update(good); buy.IsCheck = true; BuySvc.Update(buy); Value value = new Value(); value.PersonId = buy.PersonId; value.Num = Convert.ToInt32(good.Value * buy.Num); value.Date = System.DateTime.Now.ToString(); value.Other = "购物获得"; ValueSvc.Create(value); person.Value += value.Num; PersonSvc.Update(person); } return(0); }
public static int GetBuyAll(ref List <Buy> buys, ref List <Good> goods, ref List <Person> persons) { buys = BuySvc.RetrieveAll(); foreach (Buy buy in buys) { Person person = new Person(); Good good = new Good(); PersonMng.GetPersonById(buy.PersonId, ref person); PersonMng.GetGoodById(buy.GoodId, ref good); persons.Add(person); goods.Add(good); } return(0); }
public static int AddBuy(Buy buy) { BuySvc.Create(buy); return(0); }