コード例 #1
0
 public persyaratan UpdatePersyaratan(persyaratan t)
 {
     if (t == null)
     {
         throw new SystemException("Persyaratan Tidak Boleh Null");
     }
     else
     {
         return(UnitOfWorkPersyaratan.UpdatePersyaratan(t));
     }
 }
コード例 #2
0
        public IActionResult Put(int id, [FromBody] persyaratan value)
        {
            var result = service.UpdatePersyaratan(value);

            if (result != null)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #3
0
        public IActionResult Post([FromBody] persyaratan value)
        {
            var result = service.InsertPersyaratan(value);

            if (result != null)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #4
0
        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));
        }
コード例 #5
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));
        }
コード例 #6
0
 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);
             }
         }
     }
 }
コード例 #7
0
 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);
             }
         }
     }
 }