Exemplo n.º 1
0
 public ServerResult <Flower> Get(int id)
 {
     Entities.Flower flower = _flowersRepo.Get(id);
     return(new ServerResult <Flower>
     {
         Data = flower.ToDTO(),
         Success = true
     });
 }
Exemplo n.º 2
0
 public ViewResult Details(int?id)
 {
     try
     {
         int.Parse(id.Value.ToString());
         var flower = flowerRepository.Get(id.Value);
         if (flower == null)
         {
             //ViewBag.Id = id.Value;
             return(View("~/Views/Error/FlowerNotFound.cshtml", id.Value));
         }
         var detailViewModel = new HomeDetailViewModel()
         {
             Flower    = flowerRepository.Get(id ?? 1),
             TitleName = "Employee Detail"
         };
         return(View(detailViewModel));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 3
0
        public ServerResult <List <Item> > GetItemsByClientName(string clientName)
        {
            Type        priceStrategy         = Type.GetType("Superjonikai.Model.PriceStrategy." + _configuration.GetValue <string>("PriceStategy"));
            var         priceStrategyInstance = (ITotalItemPriceCalculator)Activator.CreateInstance(priceStrategy);
            var         orderId  = _orderRepo.GetAll().Where(t => t.ClientName == clientName).Select(t => t.Id).Last();
            List <Item> allItems = new List <Item>();
            Bouquet     bouquet;
            Flower      flower;
            var         orderBouquets = _bouquetOrderRepo.GetAll().Where(t => t.OrderId == orderId);
            var         orderFlowers  = _flowerOrderRepo.GetAll().Where(t => t.OrderId == orderId);

            foreach (var orderBouquet in orderBouquets)
            {
                bouquet            = _bouquetRepo.Get(orderBouquet.BouquetId).ToDTO();
                bouquet.Size       = orderBouquet.Size;
                bouquet.TotalPrice = priceStrategyInstance.CalculatePrice(bouquet);
                if (bouquet.Size.ToLower() == "medium")
                {
                    bouquet.TotalPrice = Math.Round(bouquet.Price * 1.5, 2);
                }
                else if (bouquet.Size.ToLower() == "large")
                {
                    bouquet.TotalPrice = Math.Round(bouquet.Price * 2, 2);
                }
                else
                {
                    bouquet.TotalPrice = Math.Round(bouquet.Price, 2);
                }
                allItems.Add(bouquet);
            }
            foreach (var orderFlower in orderFlowers)
            {
                flower            = _flowerRepo.Get(orderFlower.FlowerId).ToDTO();
                flower.Quantity   = orderFlower.Quantity;
                flower.TotalPrice = priceStrategyInstance.CalculatePrice(flower);
                allItems.Add(flower);
            }
            return(new ServerResult <List <Item> >
            {
                Data = allItems,
                Success = true
            });
        }