public IActionResult TaoPhongBan(TaoPhongBan model) { int ketQua = 0; var url = $"{Common.Common.ApiUrl}/phongban/taophongban"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWrite = new StreamWriter(httpWebRequest.GetRequestStream())) { var json = JsonConvert.SerializeObject(model); streamWrite.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); { using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var resKetQua = streamReader.ReadToEnd(); ketQua = int.Parse(resKetQua); } if (ketQua > 0) { TempData["ThanhCong"] = "TeamData-đã tạo thành công"; } ModelState.Clear(); return(View(new TaoPhongBan() { })); } }
public int TaoPhongBan(TaoPhongBan request) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@MaPhongBan ", request.MaPhongBan); parameters.Add("@TenPhongBan", request.TenPhongBan); var id = SqlMapper.ExecuteScalar <int>(con, "TaoPhongBan", param: parameters, commandType: CommandType.StoredProcedure); return(id); } catch (Exception ex) { throw ex; } }
public bool CreatePhongBan(TaoPhongBan phongban) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@MaPB", phongban.MaPB); parameters.Add("@TenPB", phongban.TenPB); SqlMapper.Execute(con, "CreatePhongBan", param: parameters, commandType: CommandType.StoredProcedure); return(true); } catch (Exception ex) { throw ex; } }
public int TaoPhongBan([FromBody] TaoPhongBan request) { return(_phongBanService.TaoPhongBan(request)); }
public int TaoPhongBan(TaoPhongBan request) { return(_phongBanRepository.TaoPhongBan(request)); }
public bool CreatePhongBan(TaoPhongBan phongban) { return(_PhongBanRepository.CreatePhongBan(phongban)); }
public bool Create([FromBody] TaoPhongBan phongBan) { return(_PhongBanService.CreatePhongBan(phongBan)); }