Exemplo n.º 1
0
        private Tuple <bool, string> ValidateColly(colly value)
        {
            string message = "";
            bool   valid   = true;

            if (value.PenjualanId <= 0)
            {
                message = "Id Penjualan < 0";
                valid   = false;
            }

            if (value.Weight <= 0)
            {
                valid   = false;
                message = "Berat < 0";
            }

            if (value.CollyNumber <= 0)
            {
                valid   = false;
                message = "Colly Number 0";
            }


            if (value.TypeOfWeight == TypeOfWeight.None)
            {
                valid   = false;
                message = "Type Of Weight Can Not None";
            }

            return(Tuple.Create(valid, message));
        }
Exemplo n.º 2
0
 internal async Task <colly> RemoveItem(colly selectedItem)
 {
     using (var client = new Client("Collies"))
     {
         return(await client.Delete <colly>("Delete", selectedItem.Id));
     }
 }
Exemplo n.º 3
0
 // PUT: api/Collies/5
 public async Task <IHttpActionResult> Put(int id, colly value)
 {
     try
     {
         return(Ok(await context.Put(value)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 4
0
 public Task <colly> Put(colly value)
 {
     using (var db = new OcphDbContext())
     {
         Tuple <bool, string> validateResult = ValidateColly(value);
         if (validateResult.Item1 == true)
         {
             value.Id = db.Collies.InsertAndGetLastID(value);
             if (value.Id > 0)
             {
                 return(Task.FromResult(value));
             }
             else
             {
                 throw new SystemException("Data Tidak Tersimpan");
             }
         }
         else
         {
             throw new SystemException(validateResult.Item2);
         }
     }
 }