コード例 #1
0
        public IActionResult Edit(int id)
        {
            ProductType productType = _database.GetById(id);

            ProductType productTypeViewModel = new ProductType()
            {
                ProductTypeName = productType.ProductTypeName
            };

            return(View(productTypeViewModel));
        }
コード例 #2
0
        // GET: PricePlan/Details/5
        public async Task <ActionResult> Details(int id)
        {
            var currentPricePlan = await _pricePlanRepository.GetByIdAsync(id);

            if (currentPricePlan == null)
            {
                return(HttpNotFound());
            }

            var currentProductType = _productTypeRepository.GetById(currentPricePlan.ProductTypeId);

            var priceUnitViewModels = new List <PriceUnitViewModel>();

            if (currentProductType.PriceCalculationType == PriceCalculationType.WithHeightAmount)
            {
                priceUnitViewModels = currentPricePlan.PriceUnits.Select(x => new PriceUnitViewModel
                {
                    PricePlanId = id,
                    Id          = x.Id,
                    Height      = x.Height,
                    Width       = x.Width,
                    Price       = x.Price,
                }).ToList();
            }

            var viewModel = new PricePlanDetailsViewModel
            {
                PricePlan           = currentPricePlan,
                PriceUnitViewModels = priceUnitViewModels
            };

            return(View(viewModel));
        }
コード例 #3
0
        [HttpGet("obtener/{id:int}")] // metodo GET para mostrar elemento por id
        public IActionResult GetById(int id)
        {
            var productType    = _productTypeRepository.GetById(id);        // Buscamos el elemento
            var productTypeDto = _mapper.Map <ProductTypeDto>(productType); // Mapear entitidad a dto

            return(Ok(productTypeDto));
        }
コード例 #4
0
        public ActionResult Action(tblTypeProduct objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                objSubmit.DateCreated = DateTime.Now;
                objSubmit.DateUpdated = DateTime.Now;
                objSubmit.IsDeleted   = false;
                objSubmit.IsShow      = true;
                productTypeRepository.Add(objSubmit);
            }
            else
            {
                var obj = productTypeRepository.GetById <tblTypeProduct>(objSubmit.ID);

                UpdateModel(obj);

                objSubmit.DateUpdated = DateTime.Now;

                productTypeRepository.Update(obj);
            }

            productTypeGroupMapRepository.ResetGroupOfType(objSubmit.ID, Web365Utility.Web365Utility.StringToArrayInt(Request["groupID"]));

            productTypeRepository.ResetListPicture(objSubmit.ID, Request["listPictureId"]);

            return(Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public async Task <EditProductViewModel> EditViewModel(int productId)
        {
            var currentCustomerId = await _customerIdService.GetCustomerId();

            var currentProduct = await _productRepository.GetByIdAsync(productId);

            var productTypeViewModels = await GetProductTypeViewModels();

            var currentProductType = _productTypeRepository.GetById(currentProduct.ProductTypeId);

            var pricePlanViewModels = new List <PricePlanDropDownViewModel>();
            var usePricePlan        = false;

            if (currentProductType.PriceCalculationType == PriceCalculationType.WithHeightAmount)
            {
                var result = await _pricePlanService.GetPricePlanDropDownViewModelsByIds(currentCustomerId, currentProduct.ProductTypeId);

                pricePlanViewModels = result.ToList();
                usePricePlan        = true;
            }


            var viewModel = AutoMapper.Mapper.Map <EditProductViewModel>(currentProduct);

            viewModel.ProductTypeId         = currentProduct.ProductTypeId;
            viewModel.ProductTypeViewModels = productTypeViewModels;
            viewModel.PricePlanViewModels   = pricePlanViewModels;
            viewModel.UsingPricePlan        = usePricePlan;

            return(viewModel);
        }
コード例 #6
0
        public ActionResult UsePricePlan(int productTypeId)
        {
            var currentProductType = _productTypeRepository.GetById(productTypeId);
            var viewModel          = new BoolResultViewModel
            {
                Result = currentProductType.PriceCalculationType == PriceCalculationType.WithHeightAmount
            };

            return(Json(viewModel, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
 public ProductType GetById(int?id)
 {
     if (id == null)
     {
         return(null);
     }
     if (id == 0)
     {
         return(null);
     }
     return(_repository.GetById(id));
 }
コード例 #8
0
        public async Task <IEnumerable <PricePlanDropDownViewModel> > GetPricePlanDropDownViewModelsByIds(int currentCustomerId, int productTypeId)
        {
            var currentProductType = _productTypeRepository.GetById(productTypeId);

            var viewModels = new List <PricePlanDropDownViewModel>();

            if (currentProductType.PriceCalculationType == PriceCalculationType.WithHeightAmount)
            {
                viewModels = await _pricePlanRepository.GetAll()
                             .Where(c => c.CustomerId == currentCustomerId && c.ProductTypeId == productTypeId)
                             .OrderBy(x => x.Name).Select(o => new PricePlanDropDownViewModel {
                    Id = o.Id, Name = o.Name
                }).ToListAsync();
            }

            return(viewModels);
        }
コード例 #9
0
 public ProductType GetById(int id)
 {
     return(_productTypeRepository.GetById(id));
 }
コード例 #10
0
        private string GetProductTypeNameById(int productTypeId)
        {
            var productType = _productTypeRepository.GetById(productTypeId);

            return(productType.Name);
        }
コード例 #11
0
 public void Delete(Guid id)
 {
     var entity = productTypeRepository.GetById(id);
     productTypeRepository.Delete(entity);
     productTypeRepository.SaveChanges();
 }