Exemplo n.º 1
0
 /// <summary>
 /// Called from PUT
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="returnMessage"></param>
 /// <returns></returns>
 public bool Update(orders 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);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called from DELETE
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="returnMessage"></param>
        /// <returns></returns>
        public bool Delete(string id, out string returnMessage)
        {
            returnMessage = string.Empty;
            using (var edc = new EDC())
            {
                orders obj = Get(id);

                edc.Entry(obj).State = System.Data.Entity.EntityState.Deleted;
                try
                {
                    edc.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    returnMessage = ex.Message;
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called from POST
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="returnMessage"></param>
        /// <returns></returns>
        public bool Create(orders obj, out string returnMessage)
        {
            Guid id = Guid.NewGuid();

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