public IActionResult Edit(int id) { ProductType productType = _database.GetById(id); ProductType productTypeViewModel = new ProductType() { ProductTypeName = productType.ProductTypeName }; return(View(productTypeViewModel)); }
// 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)); }
[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)); }
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)); }
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); }
public ActionResult UsePricePlan(int productTypeId) { var currentProductType = _productTypeRepository.GetById(productTypeId); var viewModel = new BoolResultViewModel { Result = currentProductType.PriceCalculationType == PriceCalculationType.WithHeightAmount }; return(Json(viewModel, JsonRequestBehavior.AllowGet)); }
public ProductType GetById(int?id) { if (id == null) { return(null); } if (id == 0) { return(null); } return(_repository.GetById(id)); }
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); }
public ProductType GetById(int id) { return(_productTypeRepository.GetById(id)); }
private string GetProductTypeNameById(int productTypeId) { var productType = _productTypeRepository.GetById(productTypeId); return(productType.Name); }
public void Delete(Guid id) { var entity = productTypeRepository.GetById(id); productTypeRepository.Delete(entity); productTypeRepository.SaveChanges(); }