コード例 #1
0
        public ActionResult Index(Event eventModel)
        {
            //eventManagement = new EventManagement();
            string currentUser = User.Identity.GetUserName();

            //eventManagement.Events = eventBAL.EditEventList(eventModel, currentUser);
            //eventManagement.PitStops = pitStop;
            return(View(eventBAL.EditEventList(eventModel, currentUser).ToList()));
        }
コード例 #2
0
        public ActionResult EventsList(Event eventModel)
        {
            //in case of editing an existing Event
            if (eventModel.EventID > 0)
            {
                Event selectedEvent = eventBAL.GetEditingValues(eventModel.EventID);
                //if no image is uploaded keep existing image
                if (eventModel.ImageFile == null)
                {
                    eventModel.ImagePath = selectedEvent.ImagePath;
                }
                //if an image is uploaded by user
                else
                {
                    string fileName  = Path.GetFileNameWithoutExtension(eventModel.ImageFile.FileName);
                    string extension = Path.GetExtension(eventModel.ImageFile.FileName);
                    fileName             = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    eventModel.ImagePath = "~/Content/Images/" + fileName;
                    fileName             = Path.Combine(Server.MapPath("~/Content/Images/"), fileName);
                    eventModel.ImageFile.SaveAs(fileName);
                }
            }
            //if a new event is created
            else
            {
                //If no image is uploaded,Use default image
                if (eventModel.ImageFile == null)
                {
                    eventModel.ImagePath = "~/Content/Images/Empty_Event_Icon.png";
                }
                //if an image is uploaded add to database
                else
                {
                    string fileName  = Path.GetFileNameWithoutExtension(eventModel.ImageFile.FileName);
                    string extension = Path.GetExtension(eventModel.ImageFile.FileName);
                    fileName             = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    eventModel.ImagePath = "~/Content/Images/" + fileName;
                    fileName             = Path.Combine(Server.MapPath("~/Content/Images/"), fileName);
                    eventModel.ImageFile.SaveAs(fileName);
                }
            }
            string currentUser = User.Identity.GetUserName();

            return(PartialView("_EventsList", eventBAL.EditEventList(eventModel, currentUser).ToList()));
        }