public IActionResult GetById(string id) { var off = Offers.Find(id); if (off == null) { return(NotFound()); } return(new ObjectResult(off)); }
public async Task <OfferModel> GetOfferById(Guid id) { var data = await _offerRepo.Find(id.ToString()); Console.WriteLine(data); return(data); }
public IActionResult Create([FromBody] Investment inv) { if (inv == null) { BadRequest(); } // TODO ein paar Berechnungen bzgl. des Crowdshare und Prüfung auf Abschluss. if (inv.Initiative) { if (inv.Name == string.Empty) { return(BadRequest()); } return(CreatedAtRoute("GetInvestment", new { controller = "Investment", id = inv.Id }, inv)); } else { var o = Offers.Find(inv.OfferId); if (o != null) { // TODO Berechnungen für nicht Initiative if (inv.Name == string.Empty) { var l = Investments.GetPendingByQuery(o.Name); inv.Name = o.Name + " - Investment-#" + (l.Count() + 1); inv.InvestmentGoal = o.InvestmentGoal; inv.LeastCrowdFraction = inv.Amount / o.InvestmentGoal * o.CrowdShare; o.TotalCrowdInvestment += inv.Amount; } Investments.Add(inv); return(CreatedAtRoute("GetInvestment", new { controller = "Investment", id = inv.Id }, inv)); } } return(NotFound()); }
public IActionResult GetById(string id) { var inv = Investments.Find(id); var off = Offers.Find(id); if (inv == null && off == null) { return(NotFound()); } if (off != null) { return(new ObjectResult(off)); } return(new ObjectResult(inv)); }
public OfferJson Get(string id) { if (!authorization.IsAuthorized()) { throw new WebFaultException(HttpStatusCode.Unauthorized); } Offer offer = offerRepository.Find(int.Parse(id)); if (offer == null) { throw new WebFaultException(HttpStatusCode.NotFound); } return(new OfferJson(offer)); }
public Offer findById(int?id) { return(repository.Find(id)); }
public OfferDto FindOffer(int id) { Offer offer = _offerRepository.Find(id); return(Mapper.Map <Offer, OfferDto>(offer)); }