Example #1
0
        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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <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);
            }
        }
Example #5
0
        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);
        }