예제 #1
0
        protected void Advertize_Click(object sender, EventArgs e)
        {
            string LoggedInUser = HttpContext.Current.User.Identity.Name;
            DateTime StartDate = Calendar1.SelectedDate;

            string StartTimeTxt = txtStartTime.Text;
            DateTime StartTime = DateTime.ParseExact(StartTimeTxt, "hh:mm tt", System.Globalization.CultureInfo.CurrentCulture);
            StartDate = StartDate.AddHours(StartTime.Hour);
            StartDate = StartDate.AddMinutes(StartTime.Minute);

            string EndTimeTxt = txtEndTime.Text;
            DateTime EndTime = DateTime.ParseExact(EndTimeTxt, "hh:mm tt", System.Globalization.CultureInfo.CurrentCulture);
            DateTime EndDate = Calendar2.SelectedDate;
            EndDate = EndDate.AddHours(EndTime.Hour);
            EndDate = EndDate.AddMinutes(EndTime.Minute);

            string CategoryName = CategoriesDropDown.SelectedItem.Text;
            int CategoryId = CategoriesDropDown.SelectedIndex;
            DataContext _db = new DataContext();
            LiveBid BidToPlace = new LiveBid {
                ProvidingUserName = LoggedInUser,
                AvailableStartTime = StartDate,
                AvailableEndTime = EndDate,
                DesiredBidPrice = Convert.ToDouble(TextBox1.Text),
                Status = true,
                CategoryID = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName).CategoryID,
                Category = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName),//fix - What if calendar entries are empty
                AppUser = _db.Users.Single(u => u.Id == LoggedInUser)
            };
            _db.LiveBids.Add(BidToPlace);
            _db.SaveChanges();
            Response.Redirect("LiveBids.aspx");
        }
예제 #2
0
 protected void Advertize_Click(object sender, EventArgs e)
 {
     string LoggedInUser = HttpContext.Current.User.Identity.Name;
     DateTime StartTime = Calendar1.SelectedDate;
     DateTime EndTime = Calendar2.SelectedDate;
     string CategoryName = CategoriesDropDown.SelectedValue;
     DataContext _db = new DataContext();
     LiveBid BidToPlace = new LiveBid {
         ProvidingUserName = LoggedInUser,
         AvailableStartTime = StartTime,
         AvailableEndTime = EndTime,
         DesiredBidPrice = Convert.ToDouble(TextBox1.Text),
         Status = true,
         Category = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName)//fix - What if calendar entries are empty
     };
     _db.LiveBids.Add(BidToPlace);
     _db.SaveChanges();
     Response.Redirect("LiveBids.aspx");
 }