public Contest Insert(Contest contest)
 {
     try
     {
         connection.Open();
         var cmd = connection.CreateCommand() as SqlCommand;
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "Contest_Insert";
         cmd.Parameters.Add(new SqlParameter("@startDate", contest.StartDate));
         cmd.Parameters.Add(new SqlParameter("@endDate", contest.EndDate));
         cmd.Parameters.Add(new SqlParameter("@shortTitle", contest.ShortTitle));
         cmd.Parameters.Add(new SqlParameter("@title", contest.Title));
         cmd.Parameters.Add(new SqlParameter("@description", contest.Description));
         cmd.Parameters.Add(new SqlParameter("@regionId", contest.RegionId));
         if (contest.ImageURL == null)
             contest.ImageURL = "";
         cmd.Parameters.Add(new SqlParameter("@imageUrl", contest.ImageURL));
         var idParameter = new SqlParameter("@ID", SqlDbType.Int) { Direction = ParameterDirection.Output };
         cmd.Parameters.Add(idParameter);
         cmd.ExecuteNonQuery();
         connection.Close();
         return contest;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public HttpResponseMessage<Contest> Post(Contest contest, HttpRequestMessage<Contest> request)
        {
            if (contest != null)
            {
                var contestDB = contestRepository.Insert(contest);

                var response = new HttpResponseMessage<Contest>(contestDB) { StatusCode = HttpStatusCode.Created };
                return response;
            }
            return new HttpResponseMessage<Contest>(null) { StatusCode = HttpStatusCode.NotFound, };
        }
Ejemplo n.º 3
0
        public ContestWinner(Contest _contest)
        {
            InitializeComponent();

            contest = _contest;

            this.Title.Text = contest.Title;

            if (Current.Instance.Earthwatcher.Id == contest.WinnerId)
            {
                this.WinnerGrid.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.WinnerName.Text = contest.Description;
                this.AnounceWinnerGrid.Visibility = System.Windows.Visibility.Visible;
            }

            this.Loaded += ContestWinner_Loaded;
            this.ShareStoryBoard.Completed += ShareStoryBoard_Completed;
        }