コード例 #1
0
        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"));
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static void DeleteDatabase()
 {
     using (var context = new Dining(ConnectionString))
     {
         if (context.DatabaseExists())
         {
             // delete database if it exist
             context.DeleteDatabase();
         }
     }
 }
コード例 #5
0
 public static void CreateDatabase()
 {
     using (var context = new Dining(ConnectionString))
     {
         if (!context.DatabaseExists())
         {
             // create database if it does not exist
             context.CreateDatabase();
         }
     }
 }
コード例 #6
0
 public static void DeleteDatabase()
 {
     using (var context = new Dining(ConnectionString))
     {
         if (context.DatabaseExists())
         {
             // delete database if it exist
             context.DeleteDatabase();
         }
     }
 }
コード例 #7
0
 public static void CreateDatabase()
 {
     using (var context = new Dining(ConnectionString))
     {
         if (!context.DatabaseExists())
         {
             // create database if it does not exist
             context.CreateDatabase();
         }
     }
 }
コード例 #8
0
        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());
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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);
        }