public ActionResult CreateActivity(int i = 0) { DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); string name = Request.Form[1]; string description = Request.Form[2]; int capacity = int.Parse(Request.Form[3]); decimal price = decimal.Parse(Request.Form[4]); if (DateTime.TryParse(Request.Form[5].ToString(), out DateTime resultStartTime)) { startTime = resultStartTime; } if (DateTime.TryParse(Request.Form[6].ToString(), out DateTime resultEndTime)) { endTime = resultEndTime; } int subjectId = int.Parse(Request.Form[7]); switch (subjectId) { //Jazz case 5: Jazz jazz = new Jazz { Name = name, Description = description, Capacity = capacity, Price = price, StartTime = startTime, EndTime = endTime, LocationId = 21, SubjectId = subjectId }; activityRepo.Insert(jazz); break; //Talking case 6: Talking talking = new Talking { Name = name, Description = description, Capacity = capacity, Price = price, StartTime = startTime, EndTime = endTime, LocationId = 22, SubjectId = subjectId }; activityRepo.Insert(talking); break; //Historic case 7: Walking walking = new Walking { Name = name, Description = description, Capacity = capacity, Price = price, StartTime = startTime, EndTime = endTime, LocationId = 23, SubjectId = subjectId }; activityRepo.Insert(walking); break; //Dining case 8: Dining dining = new Dining { Name = name, Description = description, Capacity = capacity, Price = price, StartTime = startTime, EndTime = endTime, LocationId = 23, SubjectId = subjectId }; activityRepo.Insert(dining); break; } return(RedirectToAction("ActivityDetails")); }
public static IList<Dining1> GetRestaurants() { IList<Dining1> restaurants; using (var context = new Dining(ConnectionString)) { restaurants = (from Dining1 d in context.Restaurants select d).ToList(); } return restaurants; }
public static IList <Dining1> GetRestaurants() { IList <Dining1> restaurants; using (var context = new Dining(ConnectionString)) { restaurants = (from Dining1 d in context.Restaurants select d).ToList(); } return(restaurants); }
public static void DeleteDatabase() { using (var context = new Dining(ConnectionString)) { if (context.DatabaseExists()) { // delete database if it exist context.DeleteDatabase(); } } }
public static void CreateDatabase() { using (var context = new Dining(ConnectionString)) { if (!context.DatabaseExists()) { // create database if it does not exist context.CreateDatabase(); } } }
public ActionResult OrderDiningTicket(int id, int amount) { Dining dining = diningRepository.GetById(id); Ticket ticket = CreateTicketFromActivity(dining, amount); if (amount != 0) { shoppingCart.AddTicket(ticket); } else { ModelState.AddModelError("Please set a correct amount.", new ArgumentException("Incorrect ticket amount")); } return(Dining()); }
public bool CreateDining(DiningCreate model) { var entity = new Dining() { Id = model.Id, NameOfRestaurant = model.NameOfRestaurant, Location = model.Location, ReservationTime = model.ReservationTime, ReservationNumber = model.ReservationNumber, }; using (var ctx = new ApplicationDbContext()) { ctx.Dinings.Add(entity); return(ctx.SaveChanges() == 1); } }
protected void btnSave_Click(object sender, EventArgs e) { Dining dining = new Dining(); dining.Name = txtAddDining.Text; db.Dinings.InsertOnSubmit(dining); db.SubmitChanges(); this.gvDining.DataBind(); //audit trail DBLogger.Log("Create", "Create Dining ", dining.Name); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "HideShowModalScript", sb.ToString(), false); }