public EventViewModels UpdateEvent(Container_Classes.Event UpdatedEvent) { // Retreieve the existing event from the data to update it. Data.Event dataEvent = _repository.Get <Data.Event>(x => x.EventID == UpdatedEvent.ID); if (dataEvent == null) { // The event does not exist in the database. return(EventNotFound()); } // Convert the type string and category string to database keys Data.Type dataType = _repository.Get <Data.Type>(x => x.Type1.Equals(UpdatedEvent.Type)); if (dataType == null) { // Could not map type to the database return(null); } // The event exists and we have it stored as data event. Let's update it. dataEvent = Container_Classes.Event.ContainerEventToDataEvent(UpdatedEvent, 1, dataType.TypeID, UpdatedEvent.Owner_ID); _repository.Update <Data.Event>(dataEvent); _repository.SaveChanges(); EventViewModels model = new EventViewModels(); model.Event = UpdatedEvent; return(model); }
public EventViewModels CreateEvent(Container_Classes.Event NewEvent) { int typeID = int.Parse(NewEvent.Type); // Convert the type string and category string to database keys Data.Type dataType = _repository.Get <Data.Type>(x => x.TypeID == typeID); if (dataType == null) { // Could not map type to the database return(null); } Data.Category dataCategory = _repository.Get <Data.Category>(x => x.Category1.Equals(NewEvent.Category)); // Convert the Container Event into a Data Event so it can be added to the database Data.Event dataEvent = Container_Classes.Event.ContainerEventToDataEvent(NewEvent, dataCategory.CategoryID, dataType.TypeID, NewEvent.Owner_ID); _repository.Add <Data.Event>(dataEvent); _repository.SaveChanges(); // Weak way of getting new event, this should break if two events have the same name! dataEvent = _repository.Get <Data.Event>(x => x.Title == NewEvent.Title); // Assign the ID to the added container object event NewEvent.ID = dataEvent.EventID; EventViewModels model = new EventViewModels(); model.Event = NewEvent; return(model); }
//get data for dropdown list for select fields of event page. public string getViewModelData() { db.Configuration.LazyLoadingEnabled = false; EventViewModels eventViewModel = new EventViewModels(); eventViewModel.AvailableCities = new List <City>(db.Cities); eventViewModel.ScEligibility = getDictionaryObj("scEligibility"); eventViewModel.EventStatus = getDictionaryObj("EventStatus"); eventViewModel.EventVisibility = getDictionaryObj("EventVisibility"); eventViewModel.EventType = getDictionaryObj("EventType"); eventViewModel.Speakers = new List <Speaker>(db.Speakers); eventViewModel.EventTechnologTags = new List <PrimaryTechnology>(db.PrimaryTechnologies); eventViewModel.EventAudienceTypeTags = new List <AudienceType>(db.AudienceTypes); var query = from t in db.Tracks select new { t.TrackID, t.TrackDisplayName }; eventViewModel.Tracks = new List <Object>(query); return(JsonConvert.SerializeObject(eventViewModel, GlobalConfiguration.Configuration.Formatters.JsonFormatter .SerializerSettings)); }
public ActionResult CreateEvent(CreateEventViewModel model) { if (SessionManager.LoggedIn == false) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { EventManager eventManager = new EventManager(); Event containerEvent = new Event(); containerEvent.Category = "All"; containerEvent.Description = model.Description; containerEvent.EndDate = Convert.ToDateTime(model.EndTime); containerEvent.Location = model.Location; containerEvent.Logo_Path = model.LogoPath; containerEvent.Owner_ID = SessionManager.SessionID; containerEvent.StartDate = Convert.ToDateTime(model.StartTime); containerEvent.Status = "ON"; containerEvent.Title = model.Title; containerEvent.Type = model.Type; EventViewModels eventModel = eventManager.CreateEvent(containerEvent); return(RedirectToAction("Events", "Home")); } return(View(model)); }
// // GET: /Event/ public ActionResult Index() { EventViewModels model = new EventViewModels(); var EventService = new EventService(); model = EventService.GetEventContent(); return(View(model)); }
public void DeleteEvent(object sender, RoutedEventArgs e) { if (_selectedEvent <= OUT_OF_RANGE || Events.Count == 0) { return; } EventViewModels.RemoveAt(_selectedEvent); _baseLayer.BaseMethods.DeleteEvent(Events[_selectedEvent]); Events.RemoveAt(_selectedEvent); SumProbabilities(); }
public void UpdateEvent(EventViewModel callEventViewModel) { if (EventViewModels.Count != Events.Count || !EventViewModels.Contains(callEventViewModel)) { return; } int index = EventViewModels.IndexOf(callEventViewModel); RenameSimilarEvents(callEventViewModel); Events[index].Name = callEventViewModel.Name; }
public ActionResult CreateEventType() { if (Session["loggedUser"] == null) { return(RedirectToAction("Login", "Account")); } EventViewModels model = new EventViewModels(); model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); }
public ActionResult Detail(string id) { //NewModel model = new NewModel(); NewService news = new NewService(); //model = news.GetNewById(id); //model = news.GetNewById(id); EventViewModels model = new EventViewModels(); var EventService = new EventService(); model = EventService.GetEventDetailContent(id); return(View(model)); }
public ActionResult AddOrEditTriggerEvent(int id = 0) { if (Session["loggedUser"] == null) { return(RedirectToAction("Login", "Account")); } EventViewModels viewModel = new EventViewModels(); if (id != 0) { viewModel = userService.GetTriggerEventById(id); } return(View(viewModel)); }
public ActionResult Create(EventViewModels model) { if (model.TriggerTypeId == (int)TriggerType_Enum.Appointment) { ModelState.Remove("TriggerEvent_Day"); model.TriggerEvent_Day = model.EventName; } else if (model.TriggerTypeId == (int)TriggerType_Enum.Enrollment) { ModelState.Remove("EventName"); model.TriggerEvent_Day = model.TriggerEvent_Day; int n; var isNumeric = int.TryParse(model.TriggerEvent_Day, out n); if (!isNumeric) { TempData["ErrorMessage"] = "Only number allow for day field of enrollment type"; model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); } } if (ModelState.IsValid) { if (!userService.CheckEventAlredyExistOrNot(model.TriggerTypeId, model.TriggerEvent_Day)) { TempData["ErrorMessage"] = "Event alredy exist, please try another day number."; model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); } DAL.TriggerEvent eventType = new DAL.TriggerEvent { TriggerEvent_Event = model.EventName, TriggerTypeId = model.TriggerTypeId, TriggerEvent_Day = model.TriggerEvent_Day, // TriggerEvent_DateTime = model.TriggerEvent_DateTime }; if (userService.AddEventType(eventType)) { return(RedirectToAction("index")); } } model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); }
public ActionResult Edit(EventViewModels model) { if (model.TriggerTypeId == (int)TriggerType_Enum.Appointment) { ModelState.Remove("TriggerEvent_Day"); model.TriggerEvent_Day = model.EventName; } else if (model.TriggerTypeId == (int)TriggerType_Enum.Enrollment) { ModelState.Remove("EventName"); model.TriggerEvent_Day = model.TriggerEvent_Day; int n; var isNumeric = int.TryParse(model.TriggerEvent_Day, out n); if (!isNumeric) { TempData["ErrorMessage"] = "Only number allow for day field of enrollment type"; model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); } } //EventViewModels viewModel = new EventViewModels(); if (ModelState.IsValid) { //if (model.StrTriggerEvent_DateTime != null) //{ // ModelState.Remove("StartTime"); // model.TriggerEvent_DateTime = Convert.ToDateTime(model.StrTriggerEvent_DateTime); //} if (model.Id != 0) { var dbResult = userService.GetTriggerEventDetailsById(model.Id); dbResult.TriggerEvent_Day = model.TriggerEvent_Day; // dbResult.TriggerEvent_DateTime = model.TriggerEvent_DateTime; if (userService.UpdateTriggerEvent(dbResult)) { return(RedirectToAction("index")); } } } return(View(model)); }
public EventViewModels EventNotFound() { // This could break if we have multiple events with the same name Data.Event dataEvent = _repository.Get <Data.Event>(x => x.Title.Equals("NOTFOUND", StringComparison.Ordinal)); if (dataEvent == null) { // We can't even find the fake event! return(null); } Container_Classes.Event containerEvent = Container_Classes.Event.DataEventToContainerEvent(dataEvent, 0, "NOTFOUND", "NOTFOUND"); EventViewModels model = new EventViewModels(); model.Event = containerEvent; return(model); }
public EventViewModels GetEventDetailContent(string id) { var data = new EventViewModels(); var config = new ConfigService(); var news = new NewService(); var block = new BlockService(); //data.ListNewDetail = news.GetNewById("34"); data.BlockFooter = block.GetBlockBySection("5"); data.HotLineTitle = config.GetConfigById("HOTLINE_TITLE").Value; data.HotLine = config.GetConfigById("HOTLINE").Value; data.SiteMain = config.GetConfigById("SITE_MAIN").Value; data.ContactTitle = config.GetConfigById("CONTACT_TITLE").Value; data.CopyRight = config.GetConfigById("COPY_RIGHT").Value; data.Email_Server = config.GetConfigById("EMAIL_CONTACT").Value; data.Pass_Email_Server = config.GetConfigById("PASS_EMAIL_SERVER").Value; data.Email_To = config.GetConfigById("EMAIL_TO").Value; data.ListNewDetail = news.GetNewById(id); return(data); }
public ActionResult Edit(int id = 0) { if (Session["loggedUser"] == null) { return(RedirectToAction("Login", "Account")); } EventViewModels viewModel = new EventViewModels(); if (id != 0) { viewModel = userService.GetTriggerEventById(id); //if(viewModel.TriggerEvent_DateTime!=null) //{ // viewModel.StrTriggerEvent_DateTime = viewModel.TriggerEvent_DateTime.Value.ToString("MM/dd/yyyy HH:mm tt"); //} } viewModel.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(viewModel)); }
public ActionResult AddOrEditTriggerEvent(EventViewModels model) { EventViewModels viewModel = new EventViewModels(); //if (ModelState.IsValid) //{ if (model.Id != 0) { var dbResult = userService.GetTriggerEventDetailsById(model.Id); dbResult.TriggerEvent_Event = model.EventName; if (userService.UpdateTriggerEvent(dbResult)) { return(RedirectToAction("_EventTypeView")); } } //} return(View(viewModel)); }
public IActionResult Add(EventViewModels model) { int id = 0; if (ModelState.IsValid) { using (IUnitOfWork unitOfWork = new UnitOfWork(_dbContext)) { var evt = unitOfWork.Events.Get(model.Id); if (evt != null) { id = evt.Id; model.Adapt(evt); evt.Categories = model.Categories.Join(","); evt.Sponsors = model.Sponsors.Join(","); evt.Speakers = model.Speakers.Join(","); evt.UpdatedDate = DateTime.Now; unitOfWork.Events.Update(evt); unitOfWork.Commit(); this.AddToastMessage("Info", "Event updated successfully", ToastType.Info); } else { var newEvent = model.Adapt <Event>(); newEvent.Created = User.Identity.Name; newEvent.Categories = model.Categories.Join(","); newEvent.Sponsors = model.Sponsors.Join(","); newEvent.Speakers = model.Speakers.Join(","); unitOfWork.Events.Add(newEvent); id = unitOfWork.Commit(); this.AddToastMessage("Info", "Event added successfully", ToastType.Info); } } } else { this.AddToastMessage("Error", "Model state is not valid", ToastType.Info); } return(View("Details", model)); }
//[Route("api/event/add")] public IActionResult Add(int id) { EventViewModels model = new EventViewModels(); ViewBag.Title = (id > 0) ? "Edit" : "Add"; try { using (IUnitOfWork unitOfWork = new UnitOfWork(_dbContext)) { var m = unitOfWork.Events.Get(id); if (m != null) { model.Title = m.Title; model.Description = m.Description; model.StartDate = m.StartDate; model.Region = m.Region; model.Format = m.Format; model.Categories = m.Categories.Split(","); model.Speakers = m.Speakers.Split(","); model.Sponsors = m.Sponsors.Split(","); model.Address = m.Address; model.City = m.City; model.State = m.State; // model = m.Adapt<EventViewModels>(); } model.CategoryList = unitOfWork.EventCategories.GetDropDown(unitOfWork); model.SpeakerList = unitOfWork.Speakers.GetDropDown(unitOfWork); model.SponsorList = unitOfWork.Sponsors.GetDropDown(unitOfWork, model.Sponsors); } } catch (Exception) { this.AddToastMessage("Error", "Somthing went wrong, please try again ", ToastType.Error); } this.AddToastMessage("Info", "Getting speaker model for edit", ToastType.Info); return(View("Add", model)); }
public ActionResult CreateEventType(EventViewModels model) { if (ModelState.IsValid) { //if (!userService.CheckAppointmentExistForPatientOrNot(model.UserId)) //{ // TempData["ErrorMessage"] = "Event already exist."; // return View(model); //} DAL.TriggerEvent eventType = new DAL.TriggerEvent { TriggerEvent_Event = model.EventName, TriggerTypeId = model.TriggerTypeId }; if (userService.AddEventType(eventType)) { return(RedirectToAction("_EventTypeView")); } } model.TriggerTypeList = userService.GetAllTriggerTypes(); return(View(model)); }
public EventViewModels CancelEvent(Container_Classes.Event containerEvent) { Data.Event dataEvent = _repository.Get <Data.Event>(x => x.EventID == containerEvent.ID); if (dataEvent == null) { // We did not find the event to cancel through the id return(EventNotFound()); } // Change the status to cancelled :( dataEvent.Status = "Cancelled"; // Push the update back to the database _repository.Update <Data.Event>(dataEvent); // Make sure we save our work! _repository.SaveChanges(); // Returned the updated event back to the view EventViewModels model = new EventViewModels(); model.Event = containerEvent; return(model); }
public IActionResult Add(EventViewModels eventViewModels) { if (ModelState.IsValid) //if validation is OK { //Fetch a single grade object where ID == select ID Grade grades = context.Grades.Single(g => g.ID == eventViewModels.EventID); Event events = new Event //Create an event instance { Title = eventViewModels.Title, Start = eventViewModels.Start, End = eventViewModels.End, Grade = grades, }; context.Events.Add(events); //add context and save to the database context.SaveChanges(); return(Redirect("Index")); } List <Grade> grad = context.Grades.ToList(); return(View(new EventViewModels(grad))); // if failed validation, reprompt the Add event form }
public IActionResult Get(int id) { EventViewModels model = new EventViewModels(); using (var unitOfWork = new UnitOfWork(_dbContext)) { var m = unitOfWork.Events.Get(id); if (m != null) { model.Title = m.Title; model.Description = m.Description; model.StartDate = m.StartDate; model.Region = m.Region; model.Format = m.Format; model.Categories = m.Categories.Split(","); model.Speakers = m.Speakers.Split(","); model.Sponsors = m.Sponsors.Split(","); model.Address = m.Address; model.City = m.City; model.State = m.State; } } return(View("Details", model)); }
public IActionResult Details(EventViewModels model) { return(View(model)); }
public bool createEvent([FromBody] EventViewModels model) { _eventService.addEvent(model.NomEvent, model.Localisation, model.MenuId, model.SalleId, model.TraiteurId, model.DecoId, model.UserId, model.NbInvite, model.Prix, model.Dates); return(true); }
public bool validS([FromBody] EventViewModels model) { _eventService.validS(model.EventId, model.value); return(true); }