コード例 #1
0
        public void Delete()
        {
            try
            {
                using (var cont = new healthychefEntities())
                {
                    System.Data.EntityKey key = cont.CreateEntityKey("hccRecurringOrders", this);
                    object originalItem       = null;

                    if (cont.TryGetObjectByKey(key, out originalItem))
                    {
                        hccRecurringOrder item = cont.hccRecurringOrders
                                                 .Where(a => a.CartItemID == this.CartItemID).SingleOrDefault();

                        if (item != null)
                        {
                            cont.hccRecurringOrders.DeleteObject(item);
                            cont.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public static List <hccRecurringOrder> GetExpiringOrders()
        {
            try
            {
                //var results = new List<hcc_GetExpiringOrders_Result>();
                var results = new List <hccRecurringOrder>();

                using (var conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["WebModules"].ConnectionString))
                {
                    using (var cmd = new SqlCommand("hcc_GetExpiringOrders", conn))
                    {
                        cmd.CommandTimeout = 180;
                        cmd.CommandType    = CommandType.StoredProcedure;

                        conn.Open();
                        SqlDataReader t = cmd.ExecuteReader();

                        if (t != null && t.HasRows)
                        {
                            while (t.Read())
                            {
                                //var order = new hcc_GetExpiringOrders_Result
                                var order = new hccRecurringOrder
                                {
                                    CartID        = t.GetInt32(0),
                                    CartItemID    = t.GetInt32(1),
                                    UserProfileID = t.GetInt32(2),
                                    //MaxDeliveryDate = t.GetDateTime(2)
                                };
                                results.Add(order);
                            }

                            t.Close();
                        }
                        conn.Close();
                    }
                }

                return(results);
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
 public static void DeleteByCartId(int CartId)
 {
     try
     {
         using (var cont = new healthychefEntities())
         {
             hccRecurringOrder item = cont.hccRecurringOrders
                                      .Where(a => a.CartID == CartId).SingleOrDefault();
             if (item != null)
             {
                 cont.hccRecurringOrders.DeleteObject(item);
                 cont.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }