public IActionResult AreaUpdate(AreaUpdate model) { var result = false; var url = "https://localhost:44354/api/area/update"; // gọi qua đường dẫn tạo 1 request với đường dẫn HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "PUT"; 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 resKetQua = streamReader.ReadToEnd(); result = bool.Parse(resKetQua); } if (result) { TempData["ThanhCong"] = "Đã cập nhật phòng ban thành công"; } else { TempData["Loi"] = "Không thể cập nhật phòng ban"; } return(View(new AreaUpdate() { })); }
public IActionResult AreaUpdate(int id) { var area = new AreaUpdate(); var url = "https://localhost:44354/api/area/get/" + id; // gọi qua đường dẫn tạo 1 request với đường dẫn HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = "GET"; var response = httpWebRequest.GetResponse(); { string responseData; Stream responseStream = response.GetResponseStream(); try { StreamReader streamReader = new StreamReader(responseStream); try { responseData = streamReader.ReadToEnd(); } finally { ((IDisposable)streamReader).Dispose(); } } finally { ((IDisposable)responseStream).Dispose(); } area = JsonConvert.DeserializeObject <AreaUpdate>(responseData); } TempData["ThanhCong"] = null; TempData["Loi"] = null; return(View(area)); }
public IActionResult Update([FromBody] AreaUpdate model) { try { var result = _areaService.Update(model); return(Ok(result)); } catch (Exception e) { return(BadRequest(e)); } }
public Area Update(AreaUpdate model) { Area area = new Area(); area.AreaName = model.AreaName; area.AreaGuid = model.AreaGuid; area.AreaGroupId = (int)model.AreaGroupId; area.CityId = (int)model.CityId; area.DriverPrice = (double)model.DriverPrice; area.Id = model.Id; _db.Entry(area).State = EntityState.Modified; _db.SaveChanges(); return(area); }
public bool AreaUpdate(AreaUpdate request) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Name", request.Name); parameters.Add("Id", request.ID); SqlMapper.Execute(con, "Areas_Update", param: parameters, commandType: CommandType.StoredProcedure); return(true); } catch (Exception ex) { throw ex; } }
public bool AreaUpdate(AreaUpdate request) { return(_areaResponsitory.AreaUpdate(request)); }
public bool AreaUpdate([FromBody] AreaUpdate request) { return(_areaService.AreaUpdate(request)); }