public CrudEvent AddEvent(CrudEvent crudEvent) { // Create Event var e = new Event(new EventId(Guid.NewGuid().ToString().Substring(31)), new ClientId(crudEvent.ClientId), new EventTitle(crudEvent.Title), new EventDescription(crudEvent.Description), new Location(crudEvent.Address, crudEvent.LocationType), new EventDate(crudEvent.StartsAt.Year, crudEvent.StartsAt.Month, crudEvent.StartsAt.Day, crudEvent.StartsAt.Hour, crudEvent.StartsAt.Minute), new EventDate(crudEvent.EndsAt.Year, crudEvent.EndsAt.Month, crudEvent.EndsAt.Day, crudEvent.EndsAt.Hour, crudEvent.EndsAt.Minute), crudEvent.Type, crudEvent.Audience, new EventPublishDate(crudEvent.PublishDate), crudEvent.IsActive); var eFromDB = _eventsRepository.AddEvent(e); crudEvent.Id = eFromDB.Id.Value; // Create Pictures var pictures = crudEvent.Pictures .Where(p => p != null) .Select(p => new Picture(new EventId(crudEvent.Id), null, p)) .ToList(); _picturesRepository.AddPicturesToEvent(pictures); return(crudEvent); }
public ActionResult Create([Bind(Include = "EventId,eventSoort")] Event @event) { if (ModelState.IsValid) { repo.AddEvent(@event); repo.SaveChanges(); return(RedirectToAction("Index")); } return(View(@event)); }
public async Task <IActionResult> EditCar(CarVm carVm) { if (carVm.Event.EventType == EventType.Cleaning) { carVm.Car.Cleaning = false; } if (carVm.Event.EventType == EventType.Service) { carVm.Car.Service = false; } //var car = _carRepository.GetCarById(id); _carRepository.UpdateCar(carVm.Car); _eventsRepository.AddEvent(carVm); return(RedirectToAction(nameof(Index))); }
/// <summary> /// Gets the and apply event. /// </summary> /// <param name="id">The id.</param> /// <param name="event">The @event.</param> /// <returns></returns> public AggregateRoot <TEntity, TId> GetAndApplyEvent(TId id, IDomainEvent <TEntity> @event) { var entityEventSource = _repository.AddEvent(id, @event); return(CreateAggregateRoot(id, entityEventSource)); }
public async Task <JsonResult> AddOrUpdateEvents(Events events) { var files = HttpContext.Request.Form.Files; IFormFile file; try { if (events != null) { //Yeni Event oluşturma if (events.Id == 0) { Events newEvent = new Events(); newEvent.IconName = events.IconName; newEvent.ShowOnPage = events.ShowOnPage; newEvent.Title = events.Title; newEvent.PopupState = events.PopupState; newEvent.Content = events.Content; //image save if (files != null) { file = files[0]; if (file != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } newEvent.PhotoPath = file.FileName; eventsRepository.AddEvent(newEvent); } else { eventsRepository.AddEvent(newEvent); } } } else { var oldEvent = eventsRepository.GetEvent(events.Id); oldEvent.IconName = events.IconName; oldEvent.PopupState = events.PopupState; oldEvent.ShowOnPage = events.ShowOnPage; oldEvent.Title = events.Title; oldEvent.Content = events.Content; if (files.Count > 0) { file = files[0]; if (file != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } var oldEventPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", oldEvent.PhotoPath); System.IO.File.Delete(oldEventPath); oldEvent.PhotoPath = file.FileName; eventsRepository.UpdateEvent(oldEvent); } else { eventsRepository.UpdateEvent(oldEvent); } } else { eventsRepository.UpdateEvent(oldEvent); } } return(Json(1)); } return(Json(0)); } catch (Exception e) { return(Json(-1)); } }