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); }
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, "Ошибка"); } }
// GET: api/card/5 public Card Get(int id) { var card = _rep.GetById(id); card.Pet = _pet.GetById(card.PetId); return(card); }
public CardAddViewModel(int cardId) { _cardRepository = new CardRepository(); if (cardId > 0) { InitViewModel(_cardRepository.GetById(cardId, true)); } }
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")); } }
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); }
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); }
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); }
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); }
public CardAddViewModel(Card arg) { _cardRepository = new CardRepository(); InitViewModel(_cardRepository.GetById(arg.Id, true)); }
public Card GetCard(int cardId) { ICardRepository cr = new CardRepository(); return(cr.GetById(cardId)); }
public Card Get(int id) { return(db.GetById(id)); }