public stt AddNewItem(int manifestId, stt item) { try { using (var db = new OcphDbContext()) { var result = db.Manifests.Where(O => O.Id == manifestId).FirstOrDefault(); if (result == null) { throw new SystemException("Data Manifest Tidak Ditemukan"); } else { item.Id = db.STT.InsertAndGetLastID(item); if (item.Id <= 0) { throw new SystemException("Data tidak tersimpan"); } else { return(item); } } } } catch (Exception ex) { throw new SystemException(ex.Message); } }
public IHttpActionResult updateitem(int id, stt item) { try { return(Ok(context.UpdateItem(id, item))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult AddItem(int id, stt data) { try { if (data == null) { throw new SystemException("Periksa Kembali Data Anda"); } return(Ok(context.AddNewItem(id, data))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public stt UpdateItem(int id, stt item) { using (var db = new OcphDbContext()) { try { var saved = db.STT.Update(O => new { O.Pcs, O.Reciever, O.RecieverAddress, O.ShippingBy, O.Shiper, O.ShiperAddress, O.WeightType, O.WeightValue, O.CityId }, item, O => O.Id == item.Id); if (saved) { return(item); } throw new SystemException("Data Tidak Tersimpan"); } catch (Exception ex) { throw new SystemException(ex.Message); } } }