public async Task <ResponseDto <BaseModelDto> > EditCalendar(string calendarId, EditCalendarBindingModel model) { var response = new ResponseDto <BaseModelDto>(); var service = await _googleCalendarService.GetCalendarService(); if (service == null) { response.Errors.Add(ServiceErrors.SERVICE_ERROR); return(response); } var calendars = await GetListOfCalendars(); if (calendars.ErrorOccurred) { response.Errors.Add(ServiceErrors.STH_WENT_WRONG_ERROR); return(response); } var exist = calendars.Object.CalendarList.Exists(cal => cal.Id == calendarId); if (!exist) { response.Errors.Add(ServiceErrors.CALENDAR_DOES_NOT_EXIST_ERROR); return(response); } var calendar = await service.Calendars.Get(calendarId).ExecuteAsync(); calendar.Summary = model.Summary; var dbCalendar = await _calendarRepository.GetById(calendarId); if (dbCalendar == null) { response.Errors.Add(ServiceErrors.CALENDAR_DOES_NOT_EXIST_ERROR); return(response); } var updatedCalendar = await service.Calendars.Update(calendar, calendar.Id).ExecuteAsync(); dbCalendar.Summary = model.Summary; await _calendarRepository.Edit(dbCalendar); return(response); }