public persyaratan UpdatePersyaratan(persyaratan t) { if (t == null) { throw new SystemException("Persyaratan Tidak Boleh Null"); } else { return(UnitOfWorkPersyaratan.UpdatePersyaratan(t)); } }
public IActionResult Put(int id, [FromBody] persyaratan value) { var result = service.UpdatePersyaratan(value); if (result != null) { return(Ok(result)); } else { return(BadRequest()); } }
public IActionResult Post([FromBody] persyaratan value) { var result = service.InsertPersyaratan(value); if (result != null) { return(Ok(result)); } else { return(BadRequest()); } }
public void DeleteTest() { //expected NotNull , actual NotNull persyaratan kat = new persyaratan(); A.CallTo(() => unitWork.DeletePersyaratan(1)) .WithAnyArguments() .Returns(true); Assert.NotNull(service.DeletePersyaratan(1)); //when Id persyaratan 0 ecpected Thrw, actual Trow Assert.Throws <SystemException>(() => service.DeletePersyaratan(0)); }
public void UpdateTest() { //expected NotNull , actual NotNull persyaratan kat = new persyaratan(); A.CallTo(() => unitWork.UpdatePersyaratan(new persyaratan())) .WithAnyArguments() .Returns(new persyaratan()); Assert.NotNull(service.UpdatePersyaratan(kat)); //when persyaratan Null ecpected Null, actual Null persyaratan itemnull = null; Assert.Throws <SystemException>(() => service.UpdatePersyaratan(null)); }
public persyaratan UpdatePersyaratan(persyaratan t) { if (t == null) { throw new ArgumentNullException("persyaratan", "persyaratan IsNull"); } else { using (var db = new OcphDbContext()) { var isUpdated = db.Persyaratans.Update(O => new { O.Nama, O.Keterangan }, t, O => O.Id == t.Id); if (isUpdated) { return(t); } else { return(null); } } } }
public persyaratan InsertPersyaratan(persyaratan t) { if (t == null) { throw new ArgumentNullException("persyaratan", "Persyaratan IsNUll"); } else { using (var db = new OcphDbContext()) { t.Id = db.Persyaratans.InsertAndGetLastID(t); if (t.Id > 0) { return(t); } else { return(null); } } } }