public ActionResult Addbillboardtype(string kode, string nama) { string userID = HttpContext.Session.GetString(SessionKeyID); AddBillboardTypeInputModel data = new AddBillboardTypeInputModel(); data.Kode = kode; data.Type = nama; JsonConvert.SerializeObject(data); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); //HTTP POST var postTask = client.PostAsJsonAsync <AddBillboardTypeInputModel>("AddBillboardType", data); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index", "BillboardType")); } else { TempData["CustomError"] = "Gagal menambah data. Mohon hubungi admin."; } } TempData["CustomError"] = "Terjadi kesalahan. Mohon hubungi admin."; return(RedirectToAction("Create", "BillboardType")); }
public AddBillboardTypeOutputModel Save(AddBillboardTypeInputModel data) { BillboardType temp = new BillboardType(); temp.Kode = data.Kode; temp.Type = data.Type; BillboardTypeRepository repo = new BillboardTypeRepository(db); var res = repo.Insert(temp); AddBillboardTypeOutputModel output = new AddBillboardTypeOutputModel(); output.ID = res.ID; return(output); }
public ActionResult <AddBillboardTypeResponseModel> AddBillboardType([FromBody] AddBillboardTypeInputModel data) { AddBillboardTypeResponseModel res = new AddBillboardTypeResponseModel(); try { BillboardTypeBL bl = new BillboardTypeBL(db); var x = bl.Save(data); res.data = x; res.Message = "Success get data"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }