public bool DeleteFlavor(FlavorWPF Flavor_WPF)
 {
     try
     {
         bool rtn = lck.DeleteFlavor(Flavor_WPF.ID);
         return(rtn);
     }
     catch (Exception ex)
     {
         Log("DeleteFlavor(FlavorWPF) - Error msg:" + ex.Message);
         return(false);
     }
 }
 public bool AddFlavor(FlavorWPF Flavor_WPF)
 {
     try
     {
         bool rtn = lck.AddFlavor(Flavor_WPF.ToFlavor());
         return(rtn);
     }
     catch (Exception ex)
     {
         Log("AddFlavor(FlavorWPF) - Error msg:" + ex.Message);
         return(false);
     }
 }
 public bool UpdateFlavor(int Flavor_ID, FlavorWPF Flavor_WPF)
 {
     try
     {
         bool rtn = lck.UpdateFlavor(Flavor_ID, Flavor_WPF.ToFlavor());
         return(rtn);
     }
     catch (Exception ex)
     {
         Log("UpdateFlavor(int,FlavorWPF) - Error msg:" + ex.Message);
         return(false);
     }
 }
        public DayInfoWPF GetDayInfo(string DayNumber, bool appendSO2DailyFlavors = false)
        {
            try
            {
                DayInfo day = lck.GetDayInfoAll(DayNumber);
                day.DayNumber = DayNumber;

                DayInfoWPF dayWPF = new DayInfoWPF(day);
                // extract all flavors from SOs and append to dailyBatches
                if (appendSO2DailyFlavors)
                {
                    foreach (SpecialOrderWPF SO in dayWPF.Orders)
                    {
                        // extract flavor info from Special Orders and add to Daily Flavors panel
                        foreach (SO_BatchWPF bat in SO.Batches)
                        {
                            BatchWPF tmp = new BatchWPF();
                            tmp.Day_number   = bat.Day_number;
                            tmp.Store        = SO.Store;
                            tmp.Flavor       = bat.Flavor;
                            tmp.Quantity     = bat.Quantity;
                            tmp.QuantityMini = bat.QuantityMini;
                            tmp.Requested    = true;
                            tmp.IsMini       = bat.IsMini;
                            // check to see if item already in list
                            BatchWPF found = dayWPF.DailyBatches.Find(x => x.Flavor.ID == tmp.Flavor.ID && x.IsMini == tmp.IsMini);
                            if (found == null)
                            {
                                dayWPF.DailyBatches.Add(tmp);
                            }
                            else
                            {
                                // add qty
                                found.Quantity     += tmp.Quantity;
                                found.QuantityMini += tmp.QuantityMini;
                                // updated Request flag
                                found.Requested = true;
                                // check if at both locations
                                if (found.Store.Name != tmp.Store.Name)
                                {
                                    found.BothStores = true;
                                }
                            }
                        }
                        // extract Cake info from SO and add to Daily Flavors panel
                        foreach (Cake_BatchWPF cakeBat in SO.Cakes)
                        {
                            BatchWPF tmp = new BatchWPF();
                            tmp.Day_number = SO.Day_Number;
                            tmp.Store      = SO.Store;
                            // create temporary flavorWPF that I manipulate and make custom name for
                            FlavorWPF flav = new FlavorWPF();
                            flav.Name     = cakeBat.Cake.AbvName + " " + cakeBat.Flavor.Name;
                            tmp.Flavor    = flav;
                            tmp.Quantity  = cakeBat.Quantity;
                            tmp.Requested = true;
                            tmp.IsMini    = false;

                            // check if already present in list
                            BatchWPF found = dayWPF.DailyBatches.Find(x => x.Flavor.Name == tmp.Flavor.Name);
                            if (found == null)  // not found, so add
                            {
                                dayWPF.DailyBatches.Add(tmp);
                            }
                            else  // found so sum up quantities
                            {
                                found.Quantity += tmp.Quantity;
                            }
                        }
                    }

                    // scan thru all DailyBatches and combine mini and Full for same flavor
                    List <BatchWPF> deleteList = new List <BatchWPF>();
                    for (int i = dayWPF.DailyBatches.Count - 1; i >= 0; i--)
                    {
                        BatchWPF        current = dayWPF.DailyBatches[i];
                        List <BatchWPF> found   = dayWPF.DailyBatches.FindAll(x => x.Flavor.Name == current.Flavor.Name);
                        if (found.Count > 1)
                        {
                            // combine qty/qtyMini
                            found[0].Quantity     += found[1].Quantity;
                            found[0].QuantityMini += found[1].QuantityMini;
                            // then remove duplicate from list
                            dayWPF.DailyBatches.RemoveAt(i);
                        }
                    }
                }

                return(dayWPF);
            }
            catch (Exception ex)
            {
                Log("GetDayInfo(string,bool) - Error msg:" + ex.Message);
                return(null);
            }
        }