Beispiel #1
0
        internal static void saveRoaster(CabModel mdl)
        {
            CabBooking cabBooking = mdl.roaster;
            int        addressID  = repository.getDefaultAddressID(cabBooking.ProfileID);
            int        locationID = 1;

            string[] selectedDates = cabBooking.selectedDatesString.Split(',');

            foreach (string date in selectedDates)
            {
                CabDate c = new CabDate();
                c.cabDate        = DateTime.ParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture); //DateTime.Parse(date);
                c.AddressID      = addressID;
                c.ShiftStartTime = cabBooking.ShiftStartTime;
                c.ShiftEndTime   = cabBooking.ShiftEndTime;
                c.RoasterTypeID  = cabBooking.RoasterTypeID;
                c.LocationID     = locationID;
                CabBooking existingRoaster = repository.getRoasterByMonthYear(cabBooking.ProfileID, c.cabDate.Month, c.cabDate.Year);
                if (existingRoaster != null && existingRoaster.BookingID > 0)
                {
                    List <CabDate> existingCabDateList = new List <CabDate>();
                    existingCabDateList = Utility.Deserialize <List <CabDate> >(existingRoaster.cabDate);
                    CabDate duplicate = new CabDate();
                    duplicate = existingCabDateList.FirstOrDefault(m => m.cabDate == c.cabDate);
                    if (duplicate != null && duplicate.cabDate != DateTime.MinValue)
                    {
                        existingCabDateList.Remove(duplicate);
                    }

                    existingCabDateList.Add(c);
                    existingRoaster.cabDate = Utility.Serialize <List <CabDate> >(existingCabDateList);
                    repository.SaveRoaster(existingRoaster);
                }
                else
                {
                    List <CabDate> cabDateList = new List <CabDate>();
                    cabDateList.Add(c);
                    cabBooking.cabDate = Utility.Serialize <List <CabDate> >(cabDateList);
                    cabBooking.MonthID = c.cabDate.Month;
                    cabBooking.YearID  = c.cabDate.Year;
                    repository.SaveRoaster(cabBooking);
                }
            }
        }
Beispiel #2
0
        public CabBooking getRoasterByMonthYear(int profileID, int month, int year)
        {
            DataTable  dt     = new DataTable();
            CabBooking entity = new CabBooking();

            try
            {
                paramList.Clear();
                paramList["@ProfileID"] = profileID;
                paramList["@month"]     = month;
                paramList["@year"]      = year;
                spName = "spEM_getRoasterByMonthYear";
                dt.Load(db.ExecuteQuery(spName, true, Common.Enums.SQLConnectionNames.EMDB, paramList));
                entity = Utility.ConvertFromDataTable <CabBooking>(dt).FirstOrDefault();
            }
            catch
            {
                throw;
            }


            return(entity);
        }
Beispiel #3
0
 public void SaveRoaster(CabBooking cabBooking)
 {
     try
     {
         paramList.Clear();
         //          @ int,@ProfileID int,@cabDate xml, @RoasterTypeID int, @ShiftStartTime Datetime, @ShiftEndTime Datetime,
         //@MonthID int, @YearID int
         paramList["@BookingID"] = cabBooking.BookingID;
         paramList["@ProfileID"] = cabBooking.ProfileID;
         paramList["@cabDate"]   = cabBooking.cabDate;
         //paramList["@RoasterTypeID"] = cabBooking.RoasterTypeID;
         //paramList["@ShiftStartTime"] = cabBooking.ShiftStartTime;
         //paramList["@ShiftEndTime"] = cabBooking.ShiftEndTime;
         paramList["@MonthID"] = cabBooking.MonthID;
         paramList["@YearID"]  = cabBooking.YearID;
         spName = "spEM_SaveRoaster";
         db.ExecuteNonQuery(spName, true, Common.Enums.SQLConnectionNames.EMDB, paramList);
     }
     catch
     {
         throw;
     }
 }