コード例 #1
0
        public IEnumerable <Record> Get(int flag1, int flag2)
        {
            IEnumerable <Record> records = _rep.GetAll();

            foreach (var rcd in records)
            {
                rcd.User    = _user.GetById(rcd.UserId);
                rcd.Time    = _time.GetById(rcd.TimeId);
                rcd.Service = _service.GetById(rcd.ServiceId);
                rcd.Card    = _card.GetById(rcd.CardId);
            }
            return(records);
        }
コード例 #2
0
        private void DeleteCard(Card item)
        {
            var repository  = new CardRepository();
            var card        = repository.GetById(item.Id);
            var defaultCard = repository.GetDefaultCard();

            if (card.StockUnitList != null)
            {
                var stockUnitRepository = new StockUnitRepository();
                foreach (var stockUnit in card.StockUnitList)
                {
                    stockUnit.Card = defaultCard;
                    stockUnitRepository.Update(stockUnit);
                }
            }

            try
            {
                repository.Delete(item);
            }
            catch (Exception ex)
            {
                ShowInfoMessage(ex.Message, "Ошибка");
            }
        }
コード例 #3
0
ファイル: CardController.cs プロジェクト: alinadk12/vetclinic
        // GET: api/card/5
        public Card Get(int id)
        {
            var card = _rep.GetById(id);

            card.Pet = _pet.GetById(card.PetId);
            return(card);
        }
コード例 #4
0
ファイル: CardAddViewModel.cs プロジェクト: kyleabrock/Stock
 public CardAddViewModel(int cardId)
 {
     _cardRepository = new CardRepository();
     if (cardId > 0)
     {
         InitViewModel(_cardRepository.GetById(cardId, true));
     }
 }
コード例 #5
0
 public IHttpActionResult ChangeCardStatus(ChangeStatusViewModel vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid View Model"));
     }
     try
     {
         var cardDbEntity = _cardRepository.GetById(vm.Id);
         cardDbEntity.Status = vm.NewStatus;
         _cardRepository.Update(cardDbEntity);
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.Error("Could not update card status with id: " + vm.Id + " . Exception Message: " + e.Message);
         return(BadRequest("Could not update card's status"));
     }
 }
コード例 #6
0
ファイル: CardReportTests.cs プロジェクト: kyleabrock/Stock
        public void CardReportExportTest()
        {
            var cardRepository = new CardRepository();
            var card           = cardRepository.GetById(23, true);

            var templateFileName = "C:\\Work\\Stock\\Stock.Report\\bin\\Debug\\Templates\\passportTemplate.docx";
            var outFileName      = "C:\\Work\\Stock\\Stock.Report\\bin\\Debug\\Export\\passportTemplate.docx";

            var cardReport = new CardReport();

            cardReport.Export(templateFileName, outFileName, card, false);
        }
コード例 #7
0
        public bool IsCardPicked(int draftId, int cardId)
        {
            IPickRepository  pr = new PickRepository();
            IDraftRepository dr = new DraftRepository();
            ICardRepository  cr = new CardRepository();

            var draft = dr.GetById(draftId);
            var card  = cr.GetById(cardId);

            var picks = pr.GetPicksByCardAndDraft(card, draft);

            return(picks.Count > 0);
        }
コード例 #8
0
        public bool PickCard(int draftId, int memberId, int cardId)
        {
            if (!IsMyTurn(draftId, memberId))
            {
                return(FuturePickCard(draftId, memberId, cardId));
            }

            IDraftRepository  dr = new DraftRepository();
            IMemberRepository mr = new MemberRepository();
            ICardRepository   cr = new CardRepository();

            var draft  = dr.GetById(draftId);
            var member = mr.GetById(memberId);
            var card   = cr.GetById(cardId);

            if (draft.Finished || !draft.Started)
            {
                return(false);
            }

            IPickRepository pickRepository = new PickRepository();

            try
            {
                var pick = pickRepository.PickCard(draft, member, card);
            }
            catch (GenericADOException)
            {
                return(false);
            }

            var picks = pickRepository.GetPicksByDraft(draft);

            IDraftMemberPositionsRepository dmpr = new DraftMemberPositionsRepository();
            var nextMemberDraftPosition          = dmpr.GetDraftMemberPositionByDraftAndPosition(draft,
                                                                                                 GetNextPickPosition(picks.Count, draft.DraftSize));

            draft.CurrentTurn = nextMemberDraftPosition.Member;

            IDraftRepository draftRepository = new DraftRepository();

            draftRepository.Update(draft);

            TryFuturePick(draftId);

            return(true);
        }
コード例 #9
0
        public bool FuturePickCard(int draftId, int memberId, int cardId)
        {
            IFuturePickRepository fpr = new FuturePickRepository();
            IDraftRepository      dr  = new DraftRepository();
            IMemberRepository     mr  = new MemberRepository();
            ICardRepository       cr  = new CardRepository();

            var draft  = dr.GetById(draftId);
            var member = mr.GetById(memberId);
            var card   = cr.GetById(cardId);

            try
            {
                fpr.FuturePickCard(draft, member, card);
            }
            catch (GenericADOException)
            {
                return(false);
            }

            return(true);
        }
コード例 #10
0
ファイル: CardAddViewModel.cs プロジェクト: kyleabrock/Stock
 public CardAddViewModel(Card arg)
 {
     _cardRepository = new CardRepository();
     InitViewModel(_cardRepository.GetById(arg.Id, true));
 }
コード例 #11
0
        public Card GetCard(int cardId)
        {
            ICardRepository cr = new CardRepository();

            return(cr.GetById(cardId));
        }
コード例 #12
0
 public Card Get(int id)
 {
     return(db.GetById(id));
 }