public bool Update(DatePlanningForUpdateDto datePlanningForUpdate) { try { var datePlanningDto = GetById(datePlanningForUpdate.id); if (datePlanningDto == null) { return(false); } DatePlanning DataEntity = _mapper.Map <DatePlanning>(datePlanningDto); _mapper.Map(datePlanningForUpdate, DataEntity); _repository.Update(DataEntity); _repository.Save(); _logger.LogError($"Updated DatePlanning with id: {DataEntity.id}"); return(true); } catch (Exception ex) { _logger.LogError($"Something went wrong inside UpdateDatePlanning action: {ex.Message}"); throw new Exception(); } }
public DatePlanningDto GetUpcomming(int event_id) { try { DatePlanning datePlanning = _repository.GetUpcomming(event_id); if (datePlanning == null) { datePlanning = _repository.GetLast(event_id); } if (datePlanning == null) { return(null); } DatePlanningDto datePlanningDto = _mapper.Map <DatePlanningDto>(datePlanning); return(datePlanningDto); } catch (Exception ex) { _logger.LogError($"Something went wrong inside DeleteDatePlanning action: {ex.Message}"); throw new Exception(); } }
public DatePlanning GetById(int planning_id) { DatePlanning datePlanning = _datePlannings.Where(dp => dp.id == planning_id).FirstOrDefault(); datePlanning.event_date = collection.eventDates.Where(ed => ed.planning_id == datePlanning.id).First(); return(datePlanning); }
public DatePlanning GetUpcomming(int event_id) { DatePlanning datePlanning = _datePlannings.Where(dp => dp.Eventid == event_id && dp.start > new DateTime(2020, 6, 9)).FirstOrDefault(); datePlanning.event_date = collection.eventDates.Where(ed => ed.planning_id == datePlanning.id).First(); return(datePlanning); }
public void Update(DatePlanning date_planning) { DatePlanning datePlanning = _datePlannings.FirstOrDefault(dp => dp.id == date_planning.id); if (datePlanning != null) { datePlanning = date_planning; } }
public DatePlanning GetNextEvent() { DatePlanning datePlanning = _datePlannings.Where(dp => dp.start > new DateTime(2020, 6, 9)) .OrderBy(dp => dp.start) .FirstOrDefault(); datePlanning.@event = collection.events.Where(e => e.id == datePlanning.Eventid).First(); [email protected] = collection.eventGenres.Where(eg => eg.event_id == datePlanning.Eventid).ToList(); foreach (EventGenre eventGenre in [email protected]) { eventGenre.genre = collection.genres.Where(g => g.id == eventGenre.genre_id).FirstOrDefault(); } datePlanning.event_date = collection.eventDates.Where(ed => ed.planning_id == datePlanning.id).First(); return(datePlanning); }
public bool Delete(int id) { try { var datePlanningDto = GetById(id); if (datePlanningDto == null) { return(false); } DatePlanning datePlanning = _mapper.Map <DatePlanning>(datePlanningDto); _repository.Delete(datePlanning); _repository.Save(); return(true); } catch (Exception ex) { _logger.LogError($"Something went wrong inside DeleteArtist action: {ex.Message}"); throw new Exception(); } }
public DatePlanningDto GetNextEvent() { try { DatePlanning datePlanning = _repository.GetNextEvent(); if (datePlanning == null) { _logger.LogError($"no future date Planning has been found in db."); return(null); } _logger.LogInfo($"Returned all Artists from database."); var Result = _mapper.Map <DatePlanningDto>(datePlanning); return(Result); } catch (Exception ex) { _logger.LogError($"Something went wrong inside GetNextEvent action: {ex.Message}"); throw new Exception(); } }
public DatePlanningDto GetByIdWithDetails(int planning_id) { try { DatePlanning datePlanning = _repository.GetByIdWithDetails(planning_id); if (datePlanning == null) { _logger.LogError($"date Planning with id: {planning_id}, hasn't been found in db."); return(null); } _logger.LogInfo($"Returned all date Plannings from database."); var Result = _mapper.Map <DatePlanningDto>(datePlanning); return(Result); } catch (Exception ex) { _logger.LogError($"Something went wrong inside GetByIdWithDetails action: {ex.Message}"); throw new Exception(); } }
public void Delete(DatePlanning date_planning) { _datePlannings.Remove(date_planning); }
public void Create(DatePlanning date_planning) { _datePlannings.Add(date_planning); }