public ActionResult UpdateItem(ItemDTO item, string layout) { if (ModelState.IsValid) { item.created_by = 123; item.updated_by = 123; ItemBL itemBL = new ItemBL(); CommonData.ReturnCode returnCode = itemBL.UpdateData(item); if (returnCode == CommonData.ReturnCode.Success) { TempData["Success"] = "Update Successfully!"; } else { TempData["Error"] = "Update fail"; } Session["model.Item"] = null; return(RedirectToAction("Item")); } else { CheckRegex(); } if (!layout.IsNotNullOrEmpty()) { ViewBag.Layout = "~/Views/Shared/_Layout.cshtml"; } return(View("Update", LoadItemAddForm(item))); }
public void ListaTodosItensCadastrado() { //Arrange var listaItem = new List <vmItemEItemLista> { new vmItemEItemLista { Id = 1, SNome = "queijo", SUnidadeMedida = "Kg", NIdSessao = 1 }, new vmItemEItemLista { Id = 2, SNome = "presunto", SUnidadeMedida = "Kg", NIdSessao = 1 }, new vmItemEItemLista { Id = 3, SNome = "papel toalha", SUnidadeMedida = "Un", NIdSessao = 2 } }; var options = new DbContextOptionsBuilder <MarketListContext>() .UseInMemoryDatabase("ListaTodosItensCadastrado") .Options; var contexto = new MarketListContext(options); var itemBL = new ItemBL(contexto); var itemController = new ItemController(itemBL); foreach (var item in listaItem) { itemController.Post(item); } //Act var actionResult = itemController.Get(); var okResult = actionResult as ObjectResult; var retorno = okResult.Value as List <vmItemEItemLista>; //Assert Assert.AreEqual(3, retorno.Count); }
public ActionResult ItemDetele(int?id) { ItemBL bl = new ItemBL(); List <ItemsDTO> dtResult; ItemsDTO dto = new ItemsDTO(); dto.id = id; bl.SearchData(dto, out dtResult); if (dtResult.Count > 0) { int equal = bl.DeleteData(id); if (equal == 1) { TempData["Error"] = "Delete badly"; TempData["Success"] = ""; } else { TempData["Error"] = ""; TempData["Success"] = "Delete successfully"; } } else { Response.StatusCode = 404; return(null); } return(RedirectToAction("ItemSearch")); }
public ActionResult ItemUpdate(int id) { ModelState.Clear(); CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); ItemBL bl = new ItemBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); ItemsDTO dto = new ItemsDTO(); bl.SearchID(id, out dto); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ViewData["tool"] = dto.manufacture_tool.ToString().ToLower(); ViewData["make"] = dto.manufacture_make.ToString().ToLower(); ViewData["dangerous"] = dto.dangerous.ToString().ToLower(); ViewData["good"] = dto.manufacture_finished_goods.ToString().ToLower(); ViewData["category"] = dto.category_id; ViewData["inventorymeasure"] = dto.inventory_measure_id; ViewData["sizemeasure"] = dto.manufacture_size_measure_id; ViewData["weightmeasure"] = dto.manufacture_weight_measure_id; return(View(dto)); }
public static void List_Item() { System.Console.Clear(); string line = "==========================================================================================================================================="; System.Console.WriteLine(line); System.Console.WriteLine("Mã Sản Phẩm: ||Tên Sản Phẩm ||Loại Sản Phẩm ||Số Lượng ||Giá ||Size || Khuyến Mãi "); System.Console.WriteLine(line); itembl = new ItemBL(); List <Item> it = itembl.GetAllItem(); foreach (var item in it) { System.Console.WriteLine("{0,-15}{1,-25}{2,-15}{3,-15}{4,-15}{5,-15}{6,-15}", item.itemID, item.itemName, item.itemType, item.amount, item.unitPrice, item.size, item.Promotion); } ; System.Console.WriteLine("Tạo Hóa Đơn Ngay Y/N"); char ch = Convert.ToChar(System.Console.ReadLine()); switch (ch) { case 'y': CreateOrders(); break; case 'n': MenuStaff(); break; } }
public void BuscarItemPorIdRetornaObjeto() { //Arrange var objeto = new vmItemEItemLista() { Id = 1, SNome = "teste", SUnidadeMedida = "Kg", NIdSessao = 1 }; var options = new DbContextOptionsBuilder <MarketListContext>() .UseInMemoryDatabase("BuscarItemPorIdRetornaObjeto") .Options; var contexto = new MarketListContext(options); var itemBL = new ItemBL(contexto); var itemController = new ItemController(itemBL); itemController.Post(objeto); //Act var actionResult = itemController.GetId(1); var okResult = actionResult as OkObjectResult; var item = okResult.Value as vmItemEItemLista; //Assert Assert.AreEqual(objeto.SNome, item.SNome); }
public ActionResult AutoLoad(int p_lastIndex, int p_itemStatus) { decimal p_begin = SessionData.TotalRecord + 1; decimal p_end = CommonSystem.defaultEnd * p_lastIndex; var _lst = new List <ItemInfo>(); try { _lst = ItemBL.ItemLoad(p_itemStatus, p_begin, p_end); if (_lst.Count() == 0) { p_lastIndex = 0; } SessionData.TotalRecord = p_end; } catch (Exception ex) { } return(Json(new { success = -2, _lastpage = p_lastIndex, _html = RenderViewHelper.RenderRazorViewToString("~/Views/Home/_ItemList.cshtml", _lst, this.ViewData, this.ControllerContext, this.TempData) })); }
public ActionResult Update(string id, string layout) { ItemDTO dto = new ItemDTO(); if (string.IsNullOrEmpty(id)) { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Item")); } if (id.IsNumber()) { List <ItemDTO> list; ItemBL bl = new ItemBL(); bl.SearchData(new ItemSearchDTO { id = int.Parse(id) }, out list); if (list.Count > 0) { dto = list[0]; } else { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Item")); } } if (!layout.IsNotNullOrEmpty()) { ViewBag.Layout = "~/Views/Shared/_Layout.cshtml"; } return(View(LoadItemAddForm(dto))); }
public ActionResult OrderMenu() { var itemBL = new ItemBL(); ViewBag.Data = itemBL.GetItems(); return(View()); }
public ActionResult ItemUpdate(ItemsDTO model) { ViewData["tool"] = model.manufacture_tool.ToString().ToLower(); ViewData["make"] = model.manufacture_make.ToString().ToLower(); ViewData["dangerous"] = model.dangerous.ToString().ToLower(); ViewData["good"] = model.manufacture_finished_goods.ToString().ToLower(); if (ModelState.IsValid) { if (model.discontinued_datetime.IsNotNullOrEmpty()) { string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss"); model.discontinued_datetime = datetime; } model.updated_by = 65; ItemBL bl = new ItemBL(); int result = bl.UpdateData(model); if (result == 1) { TempData["Error"] = "Update badly"; TempData["Success"] = ""; return(View(model)); } else { TempData["Error"] = ""; TempData["Success"] = "Update successfully"; return(RedirectToAction("ItemUpdate")); } } else { return(View(model)); } }
public ActionResult ViewItem(string id) { ItemDTO dto = new ItemDTO(); if (string.IsNullOrEmpty(id)) { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Category")); } if (id.IsNumber()) { List <ItemDTO> list; ItemBL bl = new ItemBL(); bl.SearchData(new ItemSearchDTO { id = int.Parse(id) }, out list); if (list.Count > 0) { dto = list[0]; } else { TempData["Success"] = "0 row(s) has found."; } } return(View("View", LoadItemAddForm(dto))); }
public ActionResult Shop() { ItemBL itemBL = new ItemBL(); ShopVM shopVM = new ShopVM(); shopVM.shop = itemBL.GetItems(); return(View(shopVM)); }
public ActionResult EditItem(int id) { ItemBL itemBL = new ItemBL(); List <Item> itemList = itemBL.GetItems(); Item item = itemList.Where(u => u.ItemId == id).Single(); return(View(item)); }
public HttpResponseMessage FulfillRequest(List <ItemVM> item) { List <ItemVM> list = ItemBL.FulfillRequest(item); if (list == null) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } return(Request.CreateResponse(HttpStatusCode.OK, list)); }
public ActionResult ItemSearch(ItemsDTO item) { ItemBL bl = new ItemBL(); ItemsList model = new ItemsList(); DataTable dt; bl.SearchData(item, out dt); model.Items = CommonMethod.DataTableToList <ItemsDTO>(dt); return(View(model)); }
public void DeleteItem(Guid id) { try { var itemBL = new ItemBL(); itemBL.DeleteItem(id); } catch (Exception) { } }
public VBG01124Result Item_BuscarProducto(int idEmpresa, int codigoUsuario, string ID_Item) { try { ItemBL objItemBL = new ItemBL(); return(objItemBL.Item_BuscarProducto(idEmpresa, codigoUsuario, ID_Item)); } catch (Exception ex) { throw ex; } }
public List <gsItem_ListarResult> Item_Listar(int idEmpresa, int codigoUsuario, string Item) { try { ItemBL objItemBL = new ItemBL(); return(objItemBL.Item_Listar(idEmpresa, codigoUsuario, Item)); } catch (Exception ex) { throw ex; } }
public void Item_RegistrarPrecioClienteLista(int idEmpresa, int codigoUsuario, List <MantenimientoProductos> lstproductos) { try { ItemBL objItemBL = new ItemBL(); objItemBL.Item_RegistrarPrecioClienteLista(idEmpresa, codigoUsuario, lstproductos); } catch (Exception ex) { throw ex; } }
public void Item_EliminarProductoCliente(int idEmpresa, int codigoUsuario, decimal ID_ItemCliente) { try { ItemBL objItemBL = new ItemBL(); objItemBL.Item_EliminarProductoCliente(idEmpresa, codigoUsuario, ID_ItemCliente); } catch (Exception ex) { throw ex; } }
public Item GetItemByID(Guid id) { try { var itemBL = new ItemBL(); return(itemBL.GetItemByID(id)); } catch (Exception) { return(null); } }
public ActionResult AddItem(ItemDTO item) { try { if (ModelState.IsValid) { if (!item.code.Contains(" ")) { item.created_by = 123; ItemBL itemBL = new ItemBL(); int count = itemBL.CountData(new ItemSearchDTO() { code_key = item.code }); if (count == 0) { CommonData.ReturnCode returnCode = itemBL.InsertData(item); if (returnCode == CommonData.ReturnCode.Success) { TempData["Success"] = "Inserted Successfully!"; } else { TempData["Error"] = "Insert fail"; } Session["model.Item"] = null; } else { ModelState.AddModelError("code", "The Code already is existed! "); return(RedirectToAction("Add")); } return(RedirectToAction("Item")); } else { ModelState.AddModelError("code", "The code must not have spaces "); } } else { CheckRegex(); } } catch (DataException dex) { ModelState.AddModelError("", "Lỗi không xác định"); } return(View("Add", LoadItemAddForm(item))); }
public List <Item> GetItemByName([FromBody] string name) { try { var itemBL = new ItemBL(); List <Item> items = itemBL.GetItems(); return(items.Where(i => i.ItemName.Contains(name)).ToList()); } catch (Exception) { return(null); } }
//public object GetPayments([FromBody()] Filter[] filters, int pageNumber, int pageSize, string paymentID) //{ // var paymentBL = new PaymentBL(); // return paymentBL.GetPayments(pageNumber, pageSize, filters, paymentID); //} //[HttpPost] //[Route("invoice/{pageNumber}/{pageSize}/{paymentID}")] //[Authorize] public ActionResult EmployeeList() { try { var itemBL = new ItemBL(); ViewBag.Data = itemBL.GetItems(); return(View()); } catch (Exception) { return(null); } }
public static short ShowListItems(string title, string[] menuItems, List <Item> items, int userID) { Console.Clear(); short choice = -1; OrderBL orderBL = new OrderBL(); var table = new ConsoleTable("ID", "Tên Đồ Uống", "Giá", "Size", "Nguyên Liệu"); // "itemNameEnglish",item.ItemNameEnglish, foreach (Item item in items) { table.AddRow(item.ItemID, item.ItemName, FormatCurrency(item.ItemPrice), item.ItemSize, item.ItemResources); } table.Write(); if (items.Count <= 0) { Console.WriteLine("Không tìm thấy thông tin sản phẩm"); } ItemBL itemBL = new ItemBL(); for (int i = 0; i < menuItems.Length; i++) { Console.WriteLine((i + 1) + ". " + menuItems[i]); } Console.WriteLine("========================================="); try { Console.Write("#Lựa chọn: "); choice = Int16.Parse(Console.ReadLine()); } catch (System.Exception) { } if (choice < 0 || choice > menuItems.Length) { do { try { Console.Write("Bạn nhập sai, Hãy nhập lại! "); choice = Int16.Parse(Console.ReadLine()); } catch (System.Exception) { continue; } } while (choice < 0 || choice > menuItems.Length); } return(choice); }
public ActionResult ItemAdd(ItemsDTO model) { CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ItemBL bl = new ItemBL(); if (ModelState.IsValid) { int count = bl.CheckCode(model); if (count > 0) { TempData["Error"] = "Code already exists"; TempData["Success"] = ""; return(View(model)); } else { if (model.discontinued_datetime.IsNotNullOrEmpty() == true) { string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss"); model.discontinued_datetime = datetime; } model.created_by = 0; model.updated_by = 0; int equal = bl.InsertData(model); if (equal == 1) { TempData["Error"] = "Insert badly"; TempData["Success"] = ""; return(View(model)); } else { TempData["Error"] = ""; TempData["Success"] = "Insert successfully"; return(RedirectToAction("ItemAdd")); } } } else { return(View(model)); } }
public ActionResult DeleteItem(int id) { ItemBL itemBL = new ItemBL(); List <Item> itemList = itemBL.GetItems(); Item item = itemList.Where(u => u.ItemId == id).Single(); itemBL.DeleteItem(item); ShopVM shopVM = new ShopVM(); shopVM.shop = itemBL.GetItems(); return(RedirectToAction("Shop", "Home", shopVM)); }
public List <gsItem_ListarPrecioClienteResult> Item_ListarPrecioCliente(int idEmpresa, int codigoUsuario, string ID_Agenda, string descripcion) { ItemBL objItemBL; try { objItemBL = new ItemBL(); return(objItemBL.Item_ListarPrecioCliente(idEmpresa, codigoUsuario, ID_Agenda, descripcion)); } catch (Exception ex) { throw ex; } }
public List <gsItem_ListarStockResult> Item_ListarStock(int idEmpresa, int codigoUsuario, string nombre, decimal?ID_AlmacenAnexo) { ItemBL objItemBL; try { objItemBL = new ItemBL(); return(objItemBL.Item_ListarStock(idEmpresa, codigoUsuario, nombre, ID_AlmacenAnexo)); } catch (Exception ex) { throw ex; } }
public List <gsItem_ListarProductoResult> Item_ListarProducto(int idEmpresa, int codigoUsuario, string nombre) { ItemBL objItemBL; try { objItemBL = new ItemBL(); return(objItemBL.Item_ListarProducto(idEmpresa, codigoUsuario, nombre)); } catch (Exception ex) { throw ex; } }