示例#1
0
        public bool CancelDraft(int draftId)
        {
            var userId = Context.User.GetUserId();

            var user = _db.Users.Find(userId);

            if (user == null)
            {
                return(false);
            }

            var draft = _db.CubeDrafts
                        .Include("Broadcaster")
                        .Include("CubeDraftCards")
                        .Single(c => c.Id == draftId);

            if (draft == null || draft.Status != CubeDraftStatus.PreStart)
            {
                return(false);
            }

            //Make sure they are a broadcaster
            _draftService.EnsureBroadcaster(draft, user);

            if (draft.CubeDraftCards.Count > 0)
            {
                draft.Status           = CubeDraftStatus.ProductHandIn;
                _db.Entry(draft).State = EntityState.Modified;
                _db.SaveChanges();
                BotService.UpdateCubeStatus(draft.Id);
            }
            else
            {
                draft.Status           = CubeDraftStatus.Completed;
                _db.Entry(draft).State = EntityState.Modified;
                _db.SaveChanges();
            }

            return(true);
        }