// POST: api/Regencys public HttpResponseMessage InsertRegency(RegencyVM regencyVM) { var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter"); var result = _iRegencyService.Insert(regencyVM); if (result) { message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added"); } return(message); }
public bool Insert(RegencyVM regencyVM) { if (string.IsNullOrWhiteSpace(regencyVM.Name)) { return(status); } else { return(iRegencyRepository.Insert(regencyVM)); } }
public bool Update(int id, RegencyVM regencyVM) { if (string.IsNullOrWhiteSpace(regencyVM.Name)) { return(status); } else { var result = _regencyRepository.Update(id, regencyVM); return(result); } }
public bool Update(int id, RegencyVM regencyVM) { var get = Get(id); var getProvince = applicationContext.Provinces.SingleOrDefault(x => x.IsDelete == false && x.Id == regencyVM.ProvinceId); get.Province = getProvince; get.Update(regencyVM); applicationContext.Entry(get).State = EntityState.Modified; var result = applicationContext.SaveChanges(); return(result > 0); }
public bool Insert(RegencyVM regencyVM) { var push = new Regency(regencyVM); //ini nih foreign key var getProvince = applicationContext.Provinces.SingleOrDefault(x => x.IsDelete == false && x.Id == regencyVM.ProvinceId); push.Province = getProvince; applicationContext.Regencies.Add(push); var result = applicationContext.SaveChanges(); return(result > 0); }
public bool Insert(RegencyVM regencyVM) { var push = new Regency(regencyVM); var getProviceId = myContext.Provinces.Find(regencyVM.Province_Id); push.Province = getProviceId; myContext.Regencys.Add(push); var result = myContext.SaveChanges(); if (result > 0) { status = true; } else { status = false; } return(status); }
public HttpResponseMessage UpdateRegency(int id, RegencyVM regencyVM) { var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request"); if (string.IsNullOrWhiteSpace(id.ToString())) { message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id"); } else { var get = _iRegencyService.Update(id, regencyVM); if (get) { message = Request.CreateResponse(HttpStatusCode.OK, get); return(message); } } return(message); }
public void InsertOrUpdate(RegencyVM regencyVM) { var client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:12280/api/"); var myContent = JsonConvert.SerializeObject(regencyVM); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); if (regencyVM.Id.Equals(0)) { var result = client.PostAsync("Regencies", byteContent).Result; } else { var result = client.PutAsync("Regencies/" + regencyVM.Id, byteContent).Result; } }
public bool Update(int id, RegencyVM regencyVM) { var put = Get(id); var getProviceId = myContext.Provinces.Find(regencyVM.Province_Id); put.Province = getProviceId; put.Update(regencyVM); myContext.Entry(put).State = EntityState.Modified; var result = myContext.SaveChanges(); if (result > 0) { status = true; } else { status = false; } return(status); }
public JsonResult GetById(int id) { RegencyVM regencyVM = null; var client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:12280/api/"); var responseTask = client.GetAsync("Districts/" + id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <RegencyVM>(); readTask.Wait(); regencyVM = readTask.Result; } else { // try to find something } return(Json(regencyVM, JsonRequestBehavior.AllowGet)); }
public void Update(RegencyVM regencyVM) { this.Name = regencyVM.Name; this.UpdateDate = DateTime.Now.ToLocalTime(); }
public Regency(RegencyVM regencyVM) { this.Name = regencyVM.Name; this.CreateDate = DateTime.Now.ToLocalTime(); }
public Regency(RegencyVM regencyVM) { this.Name = regencyVM.Name; this.CreateDate = DateTimeOffset.Now.LocalDateTime; }
public void Update(RegencyVM regencyVM) { this.Name = regencyVM.Name; this.UpdateDate = DateTimeOffset.Now.LocalDateTime; }
public bool Update(int id, RegencyVM regencyVM) { return(iRegencyRepository.Update(id, regencyVM)); }