public bool CreateOrder(string user, List <Int32> moviesInCart) { List <OrderItem> orderItems = new List <OrderItem>(); var order = new DBModels.Order() { OrderDate = DateTime.Now, User = userService.GetDbUser(user) }; dbService.Add(order); var first = dbService.SaveChanges(); var id = order.Id; foreach (int movieId in moviesInCart) { orderItems.Add(new OrderItem { Order = order, Movie = dbService.Movie.Find(movieId) }); } order.OrderItem = orderItems; return(dbService.SaveChanges() == 0 ? false : true); }
/// <summary> /// Method to add album /// </summary> /// <param name="album">Album object to add to the album's collection</param> public void AddAlbum(Album album) { if (this.Albums == null) { this.Albums = new List <Album>(); } this.Albums.Add(album); DbService.Add <Album>(album); }
/// <summary> /// Method to add the photo to the album /// </summary> /// <param name="item">Photo object to add</param> public virtual void AddPhoto(Photo item) { if (this.vphotos == null) { this.m_loPhotos = new List <Photo>(); } this.vphotos.Add(item); DbService.Add <Photo>(item); }
/// <summary> /// Method to add albums /// </summary> /// <param name="albums">Albums object to add to the album's collection</param> public void AddAlbums(params Album[] albums) { if (this.Albums == null) { this.Albums = new List <Album>(); } foreach (Album item in albums) { this.Albums.Add(item); DbService.Add <Album>(item); } }
public List <string> Excute() { if (_excuted) { return(_result.Messages); } var db = new DbService <object>(Table, DataBase); switch (OperateType) { case Operate.Add: { _result = db.Add(Param); } break; case Operate.Update: { _result = db.Update(Param); } break; case Operate.Delete: { _result = db.Delete(Param["_id"] + ""); //id } break; case Operate.Find: { _result = (db.Find(Param["_id"] + "")); //id } break; case Operate.Info: { _result = (db.Info()); //id } break; case Operate.List: { _result = (db.All(Param["_searchCondition"] as Dictionary <string, string>)); } break; case Operate.Items: { _result = (db.ToSelectItems(Param["_name"] + "", Param["_value"] + "")); } break; case Operate.Download: { _result = db.Download(Param["_id"] + "", Param["_file"] + ""); } break; default: throw new NotImplementedException("不支持的操作<br/>当前想要执行的操作是:" + OperateType); } _excuted = true; Message = _result.Messages.PackString("\n"); return(_result.Messages); }