示例#1
0
 /// <summary>
 /// Called from PUT
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="returnMessage"></param>
 /// <returns></returns>
 public bool Update(stock_levels obj, out string returnMessage)
 {
     returnMessage = string.Empty;
     using (var edc = new EDC())
     {
         edc.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         try
         {
             edc.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             returnMessage = ex.Message;
             return(false);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Called from POST
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="returnMessage"></param>
        /// <returns></returns>
        public bool Create(stock_levels obj, out string returnMessage)
        {
            Guid id = Guid.NewGuid();

            obj.id        = id.ToString();
            returnMessage = id.ToString();
            using (var edc = new EDC())
            {
                edc.StockLevels.Add(obj);
                try
                {
                    edc.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    returnMessage = ex.Message;
                    return(false);
                }
            }
        }