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 <ItemForSaleDto> > GetItemForSales(string firstName)
 {
     try
     {
         List <Product> products;
         List <Service> services;
         if (!string.IsNullOrEmpty(firstName))
         {
             var user = accountMockRepository.GetAccountByFirstName(firstName);
             if (user == null)
             {
                 return(StatusCode(StatusCodes.Status400BadRequest, "User does not exist! Please check first name."));
             }
             else
             {
                 //vracamo items for sale koje je neki user dodao
                 products = productRepository.GetProductsByAccountId(user.AccountId);
                 services = serviceRepository.GetServicesByAccountId(user.AccountId);
             }
         }
         else
         {
             //vracamo sve items for sale
             products = productRepository.GetProducts();
             services = serviceRepository.GetServices();
         }
         List <ItemForSaleDto> itemForSale = new List <ItemForSaleDto>();
         itemForSale.AddRange(mapper.Map <List <ItemForSaleDto> >(products));
         itemForSale.AddRange(mapper.Map <List <ItemForSaleDto> >(services));
         if (itemForSale.Count == 0)
         {
             return(NoContent());
         }
         return(Ok(itemForSale));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }