public Spot UpdateMultipleSpots(Spot currentSpot, List<int> spotIdsToUpdate)
 {
     try
     {
         currentSpot.LastUpdatedBy = Security.GetCurrentUserId;
         currentSpot.LastUpdatedOn = DateTime.Now;
         foreach (int spotId in spotIdsToUpdate)
         {
             currentSpot.SpotId = spotId;
             currentSpot.Update();
         }
         return currentSpot;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(new Exception(string.Format("Could not Update the following list of IDs: {0}", String.Join(",", Array.ConvertAll<int, string>(spotIdsToUpdate.ToArray(), new Converter<int, string>(Convert.ToString))), ex)));
         throw new Exception("An error occurred while trying to delete the spot(s).");
     }
 }
 public Spot UpdateSpot(Spot spot)
 {
     try
     {
         spot.LastUpdatedBy = Security.GetCurrentUserId;
         spot.LastUpdatedOn = DateTime.Now;
         spot.Update();
         return spot;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occurred while trying to update the spot.");
     }
 }
 public List<SpotConflict> SaveMultiStationSpot(Spot spot, int numberOfWeeks, List<int> stationIds)
 {
     try
     {
         spot.EnteredBy = Security.GetCurrentUserId;
         spot.EnteredOn = DateTime.Now;
         spot.LastUpdatedBy = Security.GetCurrentUserId;
         spot.LastUpdatedOn = DateTime.Now;
         DataTable stations = PopulateStationIdTable(stationIds);
         List<SpotConflict> conflicts = Spot.SaveMultiStationSpot(spot, stations);
         int prevMonth = spot.Month;
         for (int i = 1; i < numberOfWeeks; i++)
         {
             spot.SpotDate = spot.SpotDate.AddDays(7);
             spot.Year = spot.SpotDate.Year;
             spot.Month = spot.SpotDate.Month;
             spot.Week = (spot.SpotDate.Month == prevMonth ? spot.Week + 1 : 1);
             prevMonth = spot.SpotDate.Month;
             foreach (SpotConflict conflict in Spot.SaveMultiStationSpot(spot, stations))
             {
                 conflicts.Add(conflict);
             }
             //conflicts.Add(Spot.SaveMultiStationSpot(spot, stations));
         }
         return conflicts;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occurred while trying to add the spot.");
     }
 }
 public SpotConflict SaveSpot(Spot spot)
 {
     try
     {
         //return InnerSaveSpot(spot);
         SpotConflict spotContflicts = new SpotConflict();
         try
         {
             InnerSaveSpot(spot);
         }
         catch (SpotConflictException)
         {
             spotContflicts = new SpotConflict(spot.SpotDate);
         }
         return spotContflicts;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occurred while trying to save the spot.");
     }
 }
 public List<SpotConflict> SaveMultipleSpots(Spot spot, int numberOfWeeks)
 {
     try
     {
         DateTime spotDate = spot.SpotDate;
         List<Spot> spots = new List<Spot>();
         List<SpotConflict> spotConflicts = new List<SpotConflict>();
         //This *should* not need to be checked as a user can not add a spot into a non-empty cell
         spots.Add(InnerSaveSpot(spot));
         Spot newSpot;
         int prevMonth = spot.Month;
         int week = spot.Week;
         for (int i = 1; i < numberOfWeeks; i++)
         {
             spotDate = spotDate.AddDays(7);
             week = (spotDate.Month == prevMonth ? week + 1 : 1);
             newSpot = new Spot(spot.StationId, spot.StationSpotId, spot.SpotTypeId
                 , spotDate, spotDate.Year, spotDate.Month, week
                 , spot.CampaignName, spot.CampaignNumber, spot.Description);
             prevMonth = spotDate.Month;
             try
             {
                 spots.Add(InnerSaveSpot(newSpot));
             }
             catch (SpotConflictException)
             {
                 spotConflicts.Add(new SpotConflict(spotDate));
             }
         }
         return spotConflicts;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occurred while trying to save the spot.");
     }
 }
 public Spot LoadSpot(int spotId)
 {
     try
     {
         Spot spot = new Spot(spotId);
         return spot;
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occurred while trying to load the spot.");
     }
 }
 /// <summary>TBD</summary>
 /// <param name="spot">TBD</param>
 /// <returns>TBD</returns>
 public Spot InnerSaveSpot(Spot spot)
 {
     spot.EnteredBy = Security.GetCurrentUserId;
     spot.EnteredOn = DateTime.Now;
     spot.LastUpdatedBy = Security.GetCurrentUserId;
     spot.LastUpdatedOn = DateTime.Now;
     spot.Save();
     return spot;
 }
 public SpotCampaignDetail GetSpotCampaignDetail(Spot spot)
 {
     try
     {
         return SpotCampaignDetail.GetSpotCampaignDetail(spot.StationId, spot.StationSpotId, spot.SpotDate, spot.CampaignName, spot.CampaignNumber);
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         throw new Exception("An error occured while trying to retrieve the Campaign detail for the selected spot.");
     }
 }
示例#9
0
 /// <summary>TBD</summary>
 /// <param name="spot">TBD</param>
 /// <param name="stations">TBD</param>
 /// <returns>TBD</returns>
 public static List<SpotConflict> SaveMultiStationSpot(Spot spot, DataTable stations)
 {
     DataSet conflicts;
     using (IO io = new IO(WebCommon.DigitalAvailsConnectionString))
     {
         using (SqlCommand cmd = IO.CreateCommandFromStoredProc("DigitalAvails_AddSpotToMultipleStations"))
         {
             cmd.Parameters.Add(Param.CreateParam("STATIONIDS", SqlDbType.Structured, stations));
             cmd.Parameters.Add(Param.CreateParam("STATIONSPOTID", SqlDbType.Int, spot.StationSpotId));
             cmd.Parameters.Add(Param.CreateParam("SPOTTYPEID", SqlDbType.Int, spot.SpotTypeId));
             cmd.Parameters.Add(Param.CreateParam("SPOTDATE", SqlDbType.Date, spot.SpotDate));
             cmd.Parameters.Add(Param.CreateParam("YEAR", SqlDbType.Int, spot.Year));
             cmd.Parameters.Add(Param.CreateParam("MONTH", SqlDbType.Int, spot.Month));
             cmd.Parameters.Add(Param.CreateParam("WEEK", SqlDbType.Int, spot.Week));
             cmd.Parameters.Add(Param.CreateParam("CAMPAIGNNAME", SqlDbType.VarChar, spot.CampaignName.Trim()));
             if (!String.IsNullOrEmpty(spot.Description.Trim()))
             {
                 cmd.Parameters.Add(Param.CreateParam("DESCRIPTION", SqlDbType.VarChar, spot.Description.Trim()));
             }
             if (!String.IsNullOrEmpty(spot.CampaignNumber.Trim()))
             {
                 cmd.Parameters.Add(Param.CreateParam("CAMPAIGNNUMBER", SqlDbType.VarChar, spot.CampaignNumber));
             }
             cmd.Parameters.Add(Param.CreateParam("ENTEREDBY", SqlDbType.VarChar, spot.EnteredBy));
             cmd.Parameters.Add(Param.CreateParam("ENTEREDON", SqlDbType.DateTime, spot.EnteredOn));
             cmd.Parameters.Add(Param.CreateParam("LASTUPDATEDBY", SqlDbType.VarChar, spot.LastUpdatedBy));
             cmd.Parameters.Add(Param.CreateParam("LASTUPDATEDON", SqlDbType.DateTime, spot.LastUpdatedOn));
             conflicts = io.ExecuteDataSetQuery(cmd);
         }
     }
     return SpotConflict.GetMultiStationSpotConflicts(conflicts);
 }