public ActionResult Delete(Product entity) { try { if (ModelState.IsValid) { var response = _productService.Update(entity); if (response.Success) { return(RedirectToAction("Index")); } else { Enumerates.TypeSource Source = (Enumerates.TypeSource)entity.Source; PopulateCategoryDropDownList(Source, entity.IdCategory); ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } else { Enumerates.TypeSource Source = (Enumerates.TypeSource)entity.Source; PopulateCategoryDropDownList(Source, entity.IdCategory); } } catch (Exception ex) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } return(View(entity)); }
public IEnumerable <Product> GetAllProducts(Enumerates.TypeSource source) { var query = _productAplication.GetAllProducts(source); var result = Mapper.Map <IEnumerable <DAC.Product> >(query); return(result); }
public IEnumerable <Category> ItemsCategory(Enumerates.TypeSource source) { var query = _productAplication.ItemsCategory(source); var result = Mapper.Map <IEnumerable <DAC.Category> >(query); return(result.Select(x => new Category { IdCategory = x.Id, Name = x.Name })); }
public IEnumerable <Category> ItemsCategory(Enumerates.TypeSource source) { IEnumerable <DAT.Category> query = new List <DAT.Category>(); if (Enumerates.TypeSource.XmlSource.Equals(source)) { query = _categoryXmlRepository.Entities.AsEnumerable(); } else if (Enumerates.TypeSource.MemorySource.Equals(source)) { query = _categoryMemoryRepository.Entities.AsEnumerable(); } var result = Mapper.Map <IEnumerable <Category> >(query); return(result); }
public IEnumerable <Product> GetAllProducts(Enumerates.TypeSource source) { IEnumerable <DAT.Product> query = new List <DAT.Product>(); if (Enumerates.TypeSource.XmlSource.Equals(source)) { query = _productXmlRepository.Entities.AsEnumerable(); } else if (Enumerates.TypeSource.MemorySource.Equals(source)) { query = _productMemoryRepository.Entities.AsEnumerable(); } var result = Mapper.Map <IEnumerable <Product> >(query); return(result); }
public StatusResponse Delete(Product entity) { try { Enumerates.TypeSource Source = (Enumerates.TypeSource)entity.Source; if (Enumerates.TypeSource.XmlSource.Equals(Source)) { _productXmlRepository.Delete(Mapper.Map <DAT.Product>(entity)); } else if (Enumerates.TypeSource.MemorySource.Equals(Source)) { _productMemoryRepository.Delete(Mapper.Map <DAT.Product>(entity)); } return(new StatusResponse { Message = "Correct Delete", Success = true }); } catch (Exception ex) { return(new StatusResponse { Message = "Error Delete", Success = false }); } }
private void PopulateCategoryDropDownList(Enumerates.TypeSource source, object selectedCategory = null) { var all = _productService.ItemsCategory(source); ViewBag.IdCategory = new SelectList(all, "IdCategory", "Name", selectedCategory); }