public ActionResult <List <Media> > GetMedia(string name) { try { List <Media> media; if (!string.IsNullOrEmpty(name)) { var user = accountMockRepository.GetAccountByFirstName(name); if (user == null) { return(StatusCode(StatusCodes.Status400BadRequest, "User does not exist! Please check first name.")); } else { //vracamo media koje je neki user dodao media = mediaRepository.GetMediaByAccountId(user.AccountId); } } else { //vracamo sve media media = mediaRepository.GetMedias(); } if (media.Count == 0) { return(NoContent()); } logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get media", null); return(Ok(media)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public ActionResult <List <Purchase> > GetPurchase(string name) { try { List <Purchase> purchases; if (!string.IsNullOrEmpty(name)) { var user = accountMockRepository.GetAccountByFirstName(name); if (user == null) { return(StatusCode(StatusCodes.Status400BadRequest, "User does not exist! Please check first name.")); } else { purchases = purchaseRepository.GetPurchaseByAccountId(user.AccountId); } } else { //vracamo sve purchases purchases = purchaseRepository.GetAllPurchase(); } if (purchases.Count == 0) { return(NoContent()); } logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get purchase", null); return(Ok(purchases)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public ActionResult <List <Service> > GetServices(string sName) { var services = serviceRepository.GetServices(sName); if (services == null || services.Count == 0) { return(NoContent()); } logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all services", null); return(Ok(mapper.Map <List <ServiceConfirmationDto> >(services))); }
public ActionResult <List <Product> > GetProducts(string pName) { var products = productRepository.GetProducts(pName); if (products == null || products.Count == 0) { return(NoContent()); } logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all products", null); return(Ok(mapper.Map <List <ProductConfirmationDto> >(products))); }
public ActionResult <List <PastPrice> > GetPastPrices([FromHeader] string key) { if (!auth.AuthorizeUser(key)) { return(StatusCode(StatusCodes.Status401Unauthorized, "Authorization failed!")); } var pastPrices = pastPriceRepository.GetPastPrices(); if (pastPrices == null || pastPrices.Count == 0) { return(NotFound()); } logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "Get all past prices", null); return(Ok(pastPrices)); }