public ActionResult Delete(string id) { string userID = HttpContext.Session.GetString(SessionKeyID); DeleteProvinceInputModel dataProvince = new DeleteProvinceInputModel(); dataProvince.ProvinsiID = Guid.Parse(id); dataProvince.UserID = Guid.Parse(userID); JsonConvert.SerializeObject(dataProvince); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); //HTTP POST var postTask = client.PostAsJsonAsync <DeleteProvinceInputModel>("DeleteProvince", dataProvince); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index", "Province")); } else { TempData["CustomError"] = "Fail to delete data. Please contact administrator."; } } TempData["CustomError"] = "Server Error. Please contact administrator."; return(RedirectToAction("Index", "Province")); }
public DeleteProviceOutputModel Delete(DeleteProvinceInputModel data) { ProvinceRepository repo = new ProvinceRepository(db); Province temp = new Province(); temp.ID = data.ProvinsiID; temp.DeletedByUserID = data.UserID; temp.DeletedDate = DateTime.Now; var res = repo.DeleteProvince(temp); DeleteProviceOutputModel xres = new DeleteProviceOutputModel(); xres.Message = "Success"; return(xres); }
public ActionResult <DeleteProvinceResponseModel> DeleteProvince([FromBody] DeleteProvinceInputModel data) { DeleteProvinceResponseModel res = new DeleteProvinceResponseModel(); try { ProvinceBL bl = new ProvinceBL(db); var res2 = bl.Delete(data); res.data = res2; res.Message = "Success get data"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }