public IActionResult AreaAdd(AreaAdd model) { var result = false; var url = "https://localhost:44354/api/area/add"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { var json = JsonConvert.SerializeObject(model); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var resResult = streamReader.ReadToEnd(); result = bool.Parse(resResult); } if (result) { TempData["ThanhCong"] = "Đã tạo phòng ban thành công"; } // ModelState.Clear(); return(View(new AreaAdd() { })); }
public bool AreaAdd(AreaAdd request) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Name", request.Name); SqlMapper.Execute(con, "Areas_Add", param: parameters, commandType: CommandType.StoredProcedure); return(true); } catch (Exception ex) { throw ex; } }
public bool AreaAdd(AreaAdd request) { return(_areaResponsitory.AreaAdd(request)); }
public bool AreaAdd([FromBody] AreaAdd request) { return(_areaService.AreaAdd(request)); }