public ActionResult Put(PrimitiveDataDTO primitiveDataDTO) { int id = primitiveDataDTO.Id; string nombre = primitiveDataDTO.Nombre; if (String.IsNullOrEmpty(nombre) || id <= 0) { return(BadRequest("Datos incorrectos. Reviselos.")); } Color color = ColorDAO.Get(_context, id); if (color == null) { return(NotFound("No se logró obtener el color que se desea editar.")); } bool colorEnUso = ColorDAO.Get(_context, nombre) != null; if (colorEnUso) { return(NotFound("El color ingresado se encuentra en uso. Ingrese otro.")); } ColorDAO.Update(_context, color, nombre); return(Ok("Color editado exitosamente.")); }
// GET: CarManufacturerClient public ActionResult Index(int id) { var listHX = new CarManufacturerDAO().ListOf(); ViewBag.HX = listHX; var listTL = new CategoryDAO().ListOf(); ViewBag.TL = listTL; var listPK = new CylinderCapacityDAO().ListOf(); ViewBag.PK = listPK; var listCL = new ColorDAO().ListOf(); ViewBag.CL = listCL; var listNews = new NewsDAO().ListAll(); ViewBag.New = listNews; var listNewPr = new ProductDAO().ListNewPro(); ViewBag.Product = listNewPr; var listAllPr = new ProductDAO().ListByIDCar(id); ViewBag.ALLPro = listAllPr; return(View()); }
public ActionResult Post(PrimitiveDataDTO primitiveDataDTO) { string nombre = primitiveDataDTO.Nombre; if (String.IsNullOrEmpty(nombre)) { return(BadRequest("Se debe ingresar un nombre de color")); } nombre = nombre.ToUpper(); Color color = ColorDAO.Get(_context, nombre); if (color != null) { return(BadRequest("Este color ya existe. Ingrese uno diferente.")); } color = ColorDAO.Add(_context, nombre); return(new JsonResult(new { Id = color.Id, Nombre = color.Descripcion, Creacion = color.FechaCreacion.ToString("dd/MM/yyyy") })); }
public List <Color> GetAllColors() { List <Color> brands = new List <Color>(); ColorDAO dao = new ColorDAO(); brands = dao.GetAllColors(); return(brands); }
// GET: Admin/ColorAdmin public ActionResult Index(string search, int page = 1, int pageSize = 10) { var iplAcc = new ColorDAO(); var model = iplAcc.ListAllPage(search, page, pageSize); ViewBag.Search = search; return(View(model)); }
public void GetExistingColors(ComboBox comboBoxColor) { Collection <Color> colorS = ColorDAO.FindAll(); foreach (Color color in colorS) { comboBoxColor.Items.Add(color.Name); } }
public object[] Get() { List <Color> colores = ColorDAO.GetAll(_context); return(colores.Select(s => new { Id = s.Id, Nombre = s.Descripcion, Creacion = s.FechaCreacion.ToString("dd/MM/yyyy") }).OrderBy(o => o.Nombre).ToArray()); }
public void Save(GemDTO packet) { Validate(packet); Color color = FormateColor(packet); Gem gem = FormateGem(packet, color); ColorDAO.Save(color); GemDAO.Save(gem); }
public string nuevoColor(string nombre, string schema) { try { return(ColorDAO.getInstance().nuevoColor(nombre, schema)); } catch (Exception e) { throw e; } }
public bool eliminarColor(int id, string nombre, string schema) { try { return(ColorDAO.getInstance().eliminarColor(id, nombre, schema)); } catch (Exception e) { throw e; } }
// color #region "ABM" public List <Color> listaColores(string schema) { try { return(ColorDAO.getInstance().listaColores(schema)); } catch (Exception e) { throw e; } }
public ActionResult Create(FeedbackModel model) { if (ModelState.IsValid) { var login = new FeedbackDAO(); var user = new Feedback(); user.id_User = model.User_ID; user.id_Product = model.Product_ID; user.star = model.Star; user.note = model.Note; var result = login.Insert(user); if (result > 0) { ViewBag.Success = "Đăng đánh giá bình luận thành công."; return(RedirectToAction("Index", "ProductClient")); } else { ModelState.AddModelError("", "Đăng đánh giá bình luận không thành công !!!"); } } var listHX = new CarManufacturerDAO().ListOf(); ViewBag.HX = listHX; var listTL = new CategoryDAO().ListOf(); ViewBag.TL = listTL; var listPK = new CylinderCapacityDAO().ListOf(); ViewBag.PK = listPK; var listCL = new ColorDAO().ListOf(); ViewBag.CL = listCL; var listAllPr = new ProductDAO().ListAll(); ViewBag.Pr = listAllPr; var listNews = new NewsDAO().ListAll(); ViewBag.New = listNews; var listNewPr = new ProductDAO().ListNewPro(); ViewBag.Product = listNewPr; return(View("Index")); }
private void Insertar() //Metodo para Insertar Colores { try { ColorDAO.getInstance().Insertar(new Clases.Color(txtColor.Text)); //Manda mensaje de confirmacion cuando se agregan los datos MessageBox.Show("Color agrego correctamente", "Color Agregado", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); mostrarColores(); //Actualiza el DataGridView } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void FindAll(ListBox listBoxGem) { Collection <Gem> gemS = GemDAO.FindAll(); Collection <Color> colorS = ColorDAO.FindAll(); foreach (Gem gem in gemS) { Color currentColor = getColor(colorS, gem.ColorId); gem.Color = currentColor; listBoxGem.DisplayMember = "Name"; listBoxGem.Items.Add(gem); } }
public ActionResult <string> Get(string nombre) { Color color = ColorDAO.Get(_context, nombre); if (color == null) { return(NotFound("No se encuentra el color buscado.")); } return(new JsonResult(new { Id = color.Id, Nombre = color.Descripcion, Creacion = color.FechaCreacion.ToString("dd/MM/yyyy") })); }
public void FindGemWithColor(string selectedItem, ListBox listBoxGem) { Collection <Gem> gemS = GemDAO.FindAll(); Collection <Color> colorS = ColorDAO.FindAll(); foreach (Gem gem in gemS) { Color currentColor = getColor(colorS, gem.ColorId); gem.Color = currentColor; listBoxGem.DisplayMember = "Name"; if (selectedItem == gem.Color.Name) { listBoxGem.Items.Add(gem); } } }
public ActionResult Delete(PrimitiveDataDTO primitiveDataDTO) { if (primitiveDataDTO == null || primitiveDataDTO.Id <= 0) { return(BadRequest("Datos incorrectos. Reviselos.")); } Color color = ColorDAO.Get(_context, primitiveDataDTO.Id); if (color == null) { return(NotFound("No se logró obtener el color que se desea eliminar.")); } ColorDAO.Delete(_context, color); return(Ok("Color eliminado exitosamente.")); }
public ActionResult Edit(Color cl) { if (ModelState.IsValid) { var dao = new ColorDAO(); var result = dao.Update(cl); if (result) { return(RedirectToAction("Index", "ColorAdmin")); } else { ModelState.AddModelError("", "Cập nhật thất bại"); } } return(View("Index")); }
public ActionResult Create(Color cl) { if (ModelState.IsValid) { var dao = new ColorDAO(); long id = dao.Insert(cl); if (id > 0) { return(RedirectToAction("Index", "ColorAdmin")); } else { ModelState.AddModelError("", "Thêm mới thất bại"); } } return(View()); }
public void DeleteColor(int id) { ColorDAO dao = new ColorDAO(); Color deleteColor = dao.GetColor(id); if (deleteColor != null) { int result = dao.DeleteColor(id); if (result < 1) { throw new Exception("No es posible eliminar el Color, por favor verificar que no existen Productos asociados al Color"); } } else { throw new Exception("El id del Color a eliminar no es válido"); } }
public void UpdateColor(int id, string name, string color) { try { name = name.TrimEnd().TrimStart(); color = color.TrimEnd().TrimStart(); } catch (Exception) { throw new Exception("No es posible actualizar el Color"); } if (!ValidateHexColor(color)) { throw new Exception("No es posible actualizar el Color, el valor no es válido"); } ColorDAO dao = new ColorDAO(); List <Color> colors = GetAllColors(); Color colorFound = colors.Find(b => b.id.Equals(id)); if (colorFound != null) { if (colors.FindAll(b => (b.name.Equals(name.ToUpperInvariant())) && (b.id != id)).Count > 0) { throw new Exception("Ya existe un Color con este nombre"); } colorFound.name = name; colorFound.color = color; int result = dao.UpdateColor(colorFound); if (result < 1) { throw new Exception("No es posible actualizar el Color"); } } else { throw new Exception("El id del Color a actualizar no es válido"); } }
// GET: Admin/Product/Create public ActionResult Create() { CarManufacturerDAO hx = new CarManufacturerDAO(); var hxList = hx.ListOf(); CategoryDAO lx = new CategoryDAO(); var lxList = lx.ListOf(); CylinderCapacityDAO dtxl = new CylinderCapacityDAO(); var dtxlList = dtxl.ListOf(); ColorDAO mx = new ColorDAO(); var mxList = mx.ListOf(); ViewBag.HX = hxList; ViewBag.LX = lxList; ViewBag.DTXL = dtxlList; ViewBag.MX = mxList; return(View()); }
public DataTable listarColor() //Metodo que obtiene de forma de lista de Color { DataTable dt = new DataTable("Color"); dt.Columns.Add("Id"); dt.Columns.Add("Color"); try { sql = "SELECT id, nombre FROM color ORDER BY id;"; List <Clases.Color> colorLista = ColorDAO.getInstance().Listar(sql); for (int i = 0; i < colorLista.Count; i++) { dt.Rows.Add(colorLista[i].id, colorLista[i].nombre); } return(dt); } catch (Exception ex) { MessageBox.Show(ex.Message); return(dt); } }
// GET: ProductClient/Details/5 public ActionResult Details(int id) { var listHX = new CarManufacturerDAO().ListOf(); ViewBag.HX = listHX; var listTL = new CategoryDAO().ListOf(); ViewBag.TL = listTL; var listCL = new ColorDAO().ListOf(); ViewBag.CL = listCL; var listAllPr = new ProductDAO().ListAll(); ViewBag.Pr = listAllPr; var model = new FeedbackDAO().ListNewFb(id); List <FeedbackModel> listFb = new List <FeedbackModel>(); foreach (var item in model) { var newFB = new FeedbackModel(); newFB.ID = item.id; newFB.Product_ID = item.id_Product; newFB.User_ID = item.id_User; newFB.User_Name = item.User == null ? string.Empty : item.User.displayname; newFB.Star = item.star; newFB.Note = item.note; listFb.Add(newFB); } ViewBag.Feedback = listFb; var pr = new ProductDAO().ViewDetail(id); return(View(pr)); }
// GET: Admin/Product/Edit/5 public ActionResult Edit(int id) { var sp = new ProductDAO().ViewDetail(id); CarManufacturerDAO hx = new CarManufacturerDAO(); var hxList = hx.ListOf(); CategoryDAO lx = new CategoryDAO(); var lxList = lx.ListOf(); CylinderCapacityDAO dtxl = new CylinderCapacityDAO(); var dtxlList = dtxl.ListOf(); ColorDAO mx = new ColorDAO(); var mxList = mx.ListOf(); ViewBag.HX = hxList; ViewBag.LX = lxList; ViewBag.DTXL = dtxlList; ViewBag.MX = mxList; return(View(sp)); }
// GET: ProductClient public ActionResult Index(string search, int page = 1, int pageSize = 20) { var listHX = new CarManufacturerDAO().ListOf(); ViewBag.HX = listHX; var listTL = new CategoryDAO().ListOf(); ViewBag.TL = listTL; var listPK = new CylinderCapacityDAO().ListOf(); ViewBag.PK = listPK; var listCL = new ColorDAO().ListOf(); ViewBag.CL = listCL; var listNews = new NewsDAO().ListAll(); ViewBag.New = listNews; var listNewPr = new ProductDAO().ListNewPro(); ViewBag.Product = listNewPr; //var listAllPr = new ProductDAO().ListOf(); //ViewBag.ALLPro = listAllPr; var iplAcc = new ProductDAO(); var model = iplAcc.ListAllPage(search, page, pageSize); ViewBag.Search = search; return(View(model)); }
public void InsertColor(string name, string color) { try { name = name.TrimEnd().TrimStart(); color = color.TrimEnd().TrimStart(); } catch (Exception) { throw new Exception("No es posible registrar el Color"); } if (!ValidateHexColor(color)) { throw new Exception("No es posible registrar el Color, el valor no es válido"); } ColorDAO dao = new ColorDAO(); List <Color> colors = GetAllColors(); if (colors.FindAll(b => b.name.ToUpperInvariant().Equals(name.ToUpperInvariant())).Count > 0) { throw new Exception("Ya existe un Color con este nombre"); } Color newColor = new Color(); newColor.name = name; newColor.color = color; int result = dao.CreateColor(newColor); if (result < 1) { throw new Exception("No es posible registrar el Color"); } }
// GET: Admin/Color/Edit/5 public ActionResult Edit(int id) { var cl = new ColorDAO().Detail(id); return(View(cl)); }
private static IEnumerable <Entities.Color> GetColors() { return(ColorDAO.GetColors()); }