public async Task <ActionResult <LoaiSanPhamModel> > PostLoaiSanPhamModel(LoaiSanPhamModel loaiSanPhamModel) { _context.LoaiSanPhamModel.Add(loaiSanPhamModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLoaiSanPhamModel", new { id = loaiSanPhamModel.ID }, loaiSanPhamModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdLoaiSp,TenLoai")] LoaiSanPhamModel loaiSanPhamModel) { if (id != loaiSanPhamModel.IdLoaiSp) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiSanPhamModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiSanPhamModelExists(loaiSanPhamModel.IdLoaiSp)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(loaiSanPhamModel)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,TenLoai,NhaCungCap,TrangThai")] LoaiSanPhamModel loaiSanPhamModel) { if (id != loaiSanPhamModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiSanPhamModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiSanPhamModelExists(loaiSanPhamModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["NhaCungCap"] = new SelectList(_context.Set <NhaCungCapModel>(), "ID", "ID", loaiSanPhamModel.NhaCungCap); return(View(loaiSanPhamModel)); }
public ActionResult TimLoaiSP(string key, int?page) { LoaiSanPhamModel spm = new LoaiSanPhamModel(); ViewBag.key = key; return(PhanTrangSP(spm.SearchByName(key), page, null)); }
public async Task <IActionResult> PutLoaiSanPhamModel(int id, LoaiSanPhamModel loaiSanPhamModel) { if (id != loaiSanPhamModel.ID) { return(BadRequest()); } _context.Entry(loaiSanPhamModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiSanPhamModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("IdLoaiSp,TenLoai")] LoaiSanPhamModel loaiSanPhamModel) { if (ModelState.IsValid) { _context.Add(loaiSanPhamModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(loaiSanPhamModel)); }
public async Task <IActionResult> Create([Bind("ID,TenLoai,NhaCungCap,TrangThai")] LoaiSanPhamModel loaiSanPhamModel) { if (ModelState.IsValid) { _context.Add(loaiSanPhamModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["NhaCungCap"] = new SelectList(_context.Set <NhaCungCapModel>(), "ID", "ID", loaiSanPhamModel.NhaCungCap); return(View(loaiSanPhamModel)); }
public LoaiSanPhamModel UpdateItem([FromBody] LoaiSanPhamModel model) { if (model.Tenloai != null) { var arrData = model.Tenloai.Split(';'); if (arrData.Length == 3) { var savePath = $@"assets/images/{arrData[0]}"; model.Tenloai = $"{savePath}"; SaveFileFromBase64String(savePath, arrData[2]); } } ILoaiSanPham.Update(model); return(model); }
public ActionResult Edit(LoaiSanPhamModel loaiSanPham) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://206.189.90.147/api/"); //HTTP POST var postTask = client.PostAsJsonAsync <LoaiSanPhamModel>("updatecategory", loaiSanPham); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(loaiSanPham)); }
public ActionResult Create(LoaiSanPhamModel loaiSanPham) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://206.189.90.147/"); //HTTP POST var postTask = client.PostAsJsonAsync <LoaiSanPhamModel>("api/create_category", loaiSanPham); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } ModelState.AddModelError(string.Empty, "Lỗi tạo tài khoản."); return(View(loaiSanPham)); }
public bool Create(LoaiSanPhamModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_loaisanpham_create", "@Maloai", model.Maloai, "@Tenloai", model.Tenloai); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public bool Update(LoaiSanPhamModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_loai_update", "@item_group_id ", model.item_group_id, "@item_group_name", model.item_group_name); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public ActionResult Edit(int id) { IEnumerable <LoaiSanPhamModel> loaiSanPhams = null; LoaiSanPhamModel loaiSanPham = new LoaiSanPhamModel(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://206.189.90.147/"); //HTTP GET var responseTask = client.GetAsync("api/getallcategory"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <List <LoaiSanPhamModel> >(); readTask.Wait(); loaiSanPhams = readTask.Result; } else //web api sent error response { //log response status here.. loaiSanPhams = Enumerable.Empty <LoaiSanPhamModel>(); ModelState.AddModelError(string.Empty, "Lỗi server."); } foreach (var i in loaiSanPhams) { if (i.id == id) { loaiSanPham = i; break; } } } return(View(loaiSanPham)); }
public LoaiSanPhamModel UpdateSanPham([FromBody] LoaiSanPhamModel model) { _itemGroupBusiness.Update(model); return(model); }
public List <LoaiSanPhamModel> GetHiearchyList(List <LoaiSanPhamModel> lstAll, LoaiSanPhamModel node) { var lstChilds = lstAll.Where(ds => ds.parent_item_group_id == node.item_group_id).ToList(); if (lstChilds.Count == 0) { return(null); } for (int i = 0; i < lstChilds.Count; i++) { var childs = GetHiearchyList(lstAll, lstChilds[i]); lstChilds[i].type = (childs == null || childs.Count == 0) ? "leaf" : ""; lstChilds[i].children = childs; } return(lstChilds.OrderBy(s => s.seq_num).ToList()); }
public bool Update(LoaiSanPhamModel model) { return(_res.Update(model)); }
public bool Create(LoaiSanPhamModel model) { return(_res.Create(model)); }
public LoaiSanPhamModel CreateLoai([FromBody] LoaiSanPhamModel model) { model.item_group_id = Guid.NewGuid().ToString(); _itemGroupBusiness.Create(model); return(model); }