public ActionResult Edit(int id, EventEdit model) { var customerService = CreateCustomerService(); var customers = customerService.GetCustomers(); var foodService = CreateFoodService(); var foods = foodService.GetFoods(); ViewBag.FoodId = new SelectList(foods, "FoodId", "Name"); ViewBag.CustomerId = new SelectList(customers, "CustomerId", "FullName"); if (!ModelState.IsValid) { return(View(model)); } if (model.EventId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateEventService(); if (service.UpdateEvent(model)) { TempData["SaveResult"] = "Your Event was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your event could not be updated."); return(View(model)); }
private void AccessLevelButtons() { if (Database.UserData.accessLevel == "Player") //checks if user is a player { EventEdit.Hide(); //hides edit button } }
public virtual Task <HttpStatusCode> SendEmailEditEvent(EventSubmission eventDetail, string updatedByEmail) { var messageSubject = $"Edit event {eventDetail.Title}"; _logger.LogInformation("Sending event edit form email"); var emailBody = new EventEdit { Title = eventDetail.Title, EventDate = eventDetail.EventDate.HasValue ? ((DateTime)eventDetail.EventDate).ToString("dddd dd MMMM yyyy") : "-", EndDate = eventDetail.EndDate.HasValue ? ((DateTime)eventDetail.EndDate).ToString("dddd dd MMMM yyyy") : "-", StartTime = eventDetail.StartTime.HasValue ? ((DateTime)eventDetail.StartTime).ToString("HH:mm") : "-", EndTime = eventDetail.EndTime.HasValue ? ((DateTime)eventDetail.EndTime).ToString("HH:mm") : "-", Frequency = !string.IsNullOrEmpty(eventDetail.Frequency) ? eventDetail.Frequency : "-", Fee = !string.IsNullOrEmpty(eventDetail.Fee) ? eventDetail.Fee : "-", Location = !string.IsNullOrEmpty(eventDetail.Location) ? eventDetail.Location : "-", SubmittedBy = !string.IsNullOrEmpty(eventDetail.SubmittedBy) ? eventDetail.SubmittedBy : "-", Description = !string.IsNullOrEmpty(eventDetail.Description) ? eventDetail.Description : "-", SubmitterEmail = !string.IsNullOrEmpty(eventDetail.SubmitterEmail) ? eventDetail.SubmitterEmail : "-", Categories = eventDetail.CategoriesList, GroupName = string.IsNullOrEmpty(eventDetail.GroupName) ? string.Empty : $"Group name: {eventDetail.GroupName}", Occurrences = eventDetail.Occurrences == 0 ? string.Empty : $"(occurs {eventDetail.Occurrences} times)", }; return(_emailClient.SendEmailToService(new EmailMessage(messageSubject, _emailClient.GenerateEmailBodyFromHtml(emailBody), _fromEmail, _configuration.GetEventSubmissionEmail(_businessId.ToString()).ToString(), eventDetail.SubmitterEmail, null))); }
/// <summary> /// Returns the edit view for an event data object /// Data fields are initialised to match data /// </summary> /// <param name="id">The id of the event to edit</param> /// <returns>The edit view, fields populated</returns> // GET: Events/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } Event @event = await _context.Events.FindAsync(id); if (@event == null || [email protected]) { return(NotFound()); } EventEdit eventEdit = new EventEdit { Id = @event.Id, Title = @event.Title, Date = @event.Date, Duration = @event.Duration, TypeId = @event.TypeId }; return(View(@eventEdit)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Duration")] EventEdit eventEdit) { if (id != @eventEdit.Id) { return(NotFound()); } if (ModelState.IsValid) { Event @event = _context.Events.Find(id); @event.Title = eventEdit.Title; @event.Duration = eventEdit.Duration; try { @event.IsActive = true; _context.Update(@event); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(@event.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(eventEdit)); }
public void AddButtonInColumns(ref DataGridView dgv, TypeButton tb, EventEdit editEvent, EventDelete deleteEvent) { switch (tb) { case TypeButton.Search: DataGridViewButtonColumn editColumn = new DataGridViewButtonColumn(); editColumn.Text = "Editar"; editColumn.Name = "Editar"; editColumn.Width = 45; editColumn.DataPropertyName = "btnDgvEdit"; dgv.Columns.Add(editColumn); editColumn.DataGridView.CellContentClick += new DataGridViewCellEventHandler(editEvent); DataGridViewButtonColumn delColumn = new DataGridViewButtonColumn(); delColumn.Text = "Deletar"; delColumn.Name = "Deletar"; delColumn.Width = 45; delColumn.DataPropertyName = "btnDgvEditDelete"; dgv.Columns.Add(delColumn); delColumn.DataGridView.CellContentClick += new DataGridViewCellEventHandler(deleteEvent); //image column //DataGridViewImageColumn img = new DataGridViewImageColumn(); //Image image = Image.FromFile(@"..\Resources\plus.png"); //img.Image = image; //dgv.Columns.Add(img); //img.HeaderText = "Image"; //img.Name = "img"; break; } }
public ActionResult Edit(int id, EventEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.EventID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } var service = CreateEventService(); if (service.UpdateEvent(model)) { TempData["SaveResult"] = "Your event has been updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your event could not be updated."); return(View(model)); }
public bool UpdateEvent(EventEdit model) { Result LocationData = GetLocationData(model.Address); using (var ctx = new ApplicationDbContext()) { var entity = ctx .Events .Single(e => e.EventId == model.EventId && e.CreatorId == _creatorId); entity.EventRange = new DateRange() { Start = model.Start, End = model.End }; entity.Type = model.Type; entity.EventTitle = model.EventTitle; entity.Address = model.Address; entity.Zip = model.Zip; entity.City = model.City; entity.State = model.State; entity.Latitude = LocationData.geometry.location.lat.ToString(); entity.Longitude = LocationData.geometry.location.lng.ToString(); entity.VolunteersNeeded = model.VolunteersNeeded; entity.EventDescription = model.EventDescription; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateEventService(); var detail = service.GetEventById(id); var customerService = CreateCustomerService(); var customers = customerService.GetCustomers(); var foodService = CreateFoodService(); var foods = foodService.GetFoods(); ViewBag.FoodId = new SelectList(foods, "FoodId", "Name", detail.FoodId); ViewBag.CustomerId = new SelectList(customers, "CustomerId", "FullName", detail.CustomerId); var model = new EventEdit { EventId = id, FullName = detail.FullName, Name = detail.FoodName, NumOfGuest = detail.NumOfGuest, Location = detail.Location, DateOfEvent = detail.DateOfEvent, //Food=detail., FoodId = detail.FoodId, //Customer = detail.Customer, CustomerId = detail.CustomerId }; return(View(model)); }
public bool UpdateEvent(EventEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Events .Single(e => e.EventId == model.EventId); var signups = ctx .SignUps //.Where(s => s.EventId == id) .ToList(); entity.EventId = model.EventId; entity.UserId = _userId; entity.Day = model.Day; entity.ServiceDate = model.ServiceDate; entity.Location = model.Location; entity.RequiredVolunteers = model.RequiredVolunteers; entity.RemainingNeed = entity.RequiredVolunteers - signups.Count(); return(ctx.SaveChanges() == 1); } }
private void HideCoachButtons() { //checks if the user is a player if (Database.UserData.accessLevel == "Player") { EventEdit.Hide(); //hides the edit button } }
public async Task EventEdit_TestNewEvent() { var newEvent = await EventEdit.NewEventEdit(); Assert.NotNull(newEvent); Assert.False(newEvent.IsValid); }
public string Update(EventEdit model, int id) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Events.Single(e => e.id == id); entity.id = model.ID; entity.BusinessID = model.BusinessID; entity.City = model.City; entity.start = model.Start; entity.end = model.Start; entity.StartDay = model.StartDay; entity.StartMonth = model.StartMonth; entity.StartYear = model.StartYear; entity.ThirdPartyWebsite = model.ThirdPartyWebsite; entity.color = model.Color; try { ctx.SaveChanges(); return("Okay"); } catch { } return("True"); } }
private void HideEditButtons() { EventEdit.Show(); //shows the edit button //Hides the changes made label and save & cancel edit buttons EventSave.Hide(); EventCancelEdit.Hide(); LabelChangesMade.Hide(); }
private void HideEditButtons() { EventEdit.Show(); //shows edit button //hides the cancel edit & save button and changes made label EventCancelEdit.Hide(); EventSave.Hide(); LabelChangesMade.Hide(); }
public async Task TestEventEdit_TestGetEvent() { var getEvent = await EventEdit.GetEventEdit(1); Assert.NotNull(getEvent); Assert.True(getEvent.IsValid); Assert.IsType <EventEdit>(getEvent); }
private void ShowEditButtons() { EventEdit.Hide(); //hides the edit button //Shows the changes made label and save & cancel edit buttons EventCancelEdit.Show(); EventSave.Show(); LabelChangesMade.Show(); LabelChangesMade.Text = "0 changes\nmade."; }
private void BuildEvent(EventEdit eventToBuild) { eventToBuild.EventName = "new event"; eventToBuild.NextDate = DateTime.Now.Add(TimeSpan.FromDays(365)); eventToBuild.IsOneTime = false; eventToBuild.Description = "doc type description"; eventToBuild.Notes = "document type notes"; eventToBuild.LastUpdatedBy = "edm"; eventToBuild.LastUpdatedDate = DateTime.Now; }
private static void CreateValidEvent(EventEdit newEvent) { newEvent.EventName = "This awesome event"; newEvent.Description = "description of awesome event"; newEvent.IsOneTime = true; newEvent.NextDate = DateTime.Now.AddDays(7); newEvent.LastUpdatedBy = "edm"; newEvent.LastUpdatedDate = DateTime.Now; newEvent.Notes = "Notes for this event"; }
private void EditOn() { //changes the enabled state of the access level and team drop down boxes so they can be edited InputAccessLevel.Enabled = true; InputTeam.Enabled = true; EventEdit.Hide(); //hides the edit button //shows the changes made label and the save & cancel edit button EventCancelEdit.Show(); EventSave.Show(); LabelChangesMade.Show(); LabelChangesMade.Text = "0 changes\nmade."; //sets the text in the changes made label }
void UnTouchInputField() { var comps = gameObject.GetComponentsInChildren <InputField>(true); int Length = comps.Length; for (int i = 0; i < Length; ++i) { InputField inputfield = comps[i]; EventEdit.Get(inputfield.gameObject).onSubmit -= onSubmit; EventEdit.Get(inputfield.gameObject).onTextChange -= onTextChange; } }
public async Task EventEdit_TestEventNameRequired() { var validEvent = await EventEdit.NewEventEdit(); CreateValidEvent(validEvent); var isObjectValidInit = validEvent.IsValid; validEvent.EventName = string.Empty; Assert.True(isObjectValidInit); Assert.False(validEvent.IsValid); }
public bool UpdateEvent(EventEdit model) { using (var ctx = new ApplicationDbContext()) { var Event = ctx.Events.Single(e => e.EventId == model.EventId); Event.Note = model.Note; Event.EventType = model.EventType; Event.ModifiedUtc = DateTimeOffset.UtcNow; Event.DogId = model.DogId; return(ctx.SaveChanges() == 1); } }
private void EditOff() { //changes the enabled state of the access level and team drop down boxes so they cant be edited InputAccessLevel.Enabled = false; InputTeam.Enabled = false; EventEdit.Show(); //shows the edit button //hides the cancel edit & save button and the changes made label EventCancelEdit.Hide(); EventSave.Hide(); LabelChangesMade.Hide(); ReloadData(); //calls on function to load the original data back into the form Changes.ResetChanges(); //calls on function to reset variables }
public async Task <ActionResult> Edit(EventEdit model, IFormFile pictureUpload = null) { ActionResult RenderEdit() { if (model.Id != 0) { var contract = _queries.GetEventForEdit(model.Id); model.CopyNonEditableProperties(contract, PermissionContext); } else { model.CopyNonEditableProperties(null, PermissionContext); } return(View("Edit", model)); } // Either series or name must be specified. If series is specified, name is generated automatically. if (model.Series.IsNullOrDefault() || model.CustomName) { // Note: name is allowed to be whitespace, but not empty. if (model.Names == null || model.Names.All(n => string.IsNullOrEmpty(n?.Value))) { ModelState.AddModelError("Names", "Name cannot be empty"); } } if (!ModelState.IsValid) { return(RenderEdit()); } var pictureData = ParsePicture(pictureUpload, "pictureUpload", ImagePurpose.Main); if (!ModelState.IsValid) { return(RenderEdit()); } int id; try { id = (await _queries.Update(model.ToContract(), pictureData)).Id; } catch (DuplicateEventNameException x) { ModelState.AddModelError("Names", x.Message); return(RenderEdit()); } return(RedirectToAction("Details", new { id })); }
// UPDATE public bool UpdateEvent(EventEdit model) { var eventEntity = _context.Events.Find(model.EventId); eventEntity.EventId = model.EventId; eventEntity.Type = model.Type; eventEntity.Description = model.Description; eventEntity.EventDate = model.EventDate; eventEntity.BreweryId = model.BreweryId; return(_context.SaveChanges() == 1); }
public async Task EventEdit_TestInsertEvent() { var newEvent = await EventEdit.NewEventEdit(); CreateValidEvent(newEvent); var savedEvent = await newEvent.SaveAsync(); Assert.NotNull(savedEvent); Assert.IsType <EventEdit>(savedEvent); Assert.True(savedEvent.Id > 0); }
public ActionResult Edit(EventEdit model) { if (!ModelState.IsValid) { var contract = Service.GetReleaseEventForEdit(model.Id); model.CopyNonEditableProperties(contract); return(View(model)); } Service.UpdateEvent(model.ToContract()); return(RedirectToAction("EventsBySeries")); }
public bool UpdateEvent(EventEdit model) { Event editEvent = _db.Events.Single(e => e.EventId == model.EventId); editEvent.Title = model.Title; editEvent.Description = model.Description; editEvent.EventTime = model.EventTime; editEvent.IsOfAge = model.IsOfAge; editEvent.ActivityId = model.ActivityId; editEvent.LocationId = model.LocationId; return(_db.SaveChanges() == 1); }
public async Task EventEdit_TestUpdateEvent() { var eventEdit = await EventEdit.GetEventEdit(1); var notesUpdate = $"These are updated Notes {DateTime.Now}"; eventEdit.Notes = notesUpdate; var result = await eventEdit.SaveAsync(); Assert.NotNull(result); Assert.Equal(notesUpdate, result.Notes); }