public async Task <IActionResult> UpdateMeetingAgendaAsync([FromBody] UpdateMeetingAgendaAc updateMeetingAgenda) { if (string.IsNullOrEmpty(updateMeetingAgenda.Name.Trim())) { return(Ok(new SharedLookUpResponse() { ErrorType = SharedLookUpResponseType.Name, HasError = true, Message = "Meeting Agenda name can't be empty" })); } else if (string.IsNullOrEmpty(updateMeetingAgenda.Code.Trim())) { return(Ok(new SharedLookUpResponse() { ErrorType = SharedLookUpResponseType.Code, HasError = true, Message = "Meeting Agenda code can't be empty" })); } else { int loggedInUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync(); if (await _iMSDbContext.MeetingAgendas.AnyAsync(x => x.Id == updateMeetingAgenda.MeetingAgendaId && x.InstituteId == loggedInUserInstituteId)) { return(Ok(await _meetingAgendaManagementRepository.UpdateMeetingAgendaAsync(updateMeetingAgenda, loggedInUserInstituteId))); } else { return(Ok(new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Meeting Agenda not found" })); } } }
/// <summary> /// Method to update MeetingAgenda - RS /// </summary> /// <param name="updateMeetingAgenda">Slab detail</param> /// <param name="instituteId">institute id</param> /// <returns>message</returns> public async Task <SharedLookUpResponse> UpdateMeetingAgendaAsync(UpdateMeetingAgendaAc updateMeetingAgenda, int instituteId) { List <MeetingAgenda> meetingAgendas = await _iMSDbContext.MeetingAgendas.Where(x => x.InstituteId == instituteId && x.Id != updateMeetingAgenda.MeetingAgendaId).ToListAsync(); bool isDuplicate = meetingAgendas.Any(x => x.Code.ToLowerInvariant() == updateMeetingAgenda.Code.ToLowerInvariant()); if (isDuplicate) { return new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Duplicate code of Meeting Agenda. Please use unique code" } } ; else { MeetingAgenda meetingAgenda = await _iMSDbContext.MeetingAgendas.FirstAsync(x => x.Id == updateMeetingAgenda.MeetingAgendaId); meetingAgenda.Name = updateMeetingAgenda.Name; meetingAgenda.Code = updateMeetingAgenda.Code; meetingAgenda.Description = updateMeetingAgenda.Description; meetingAgenda.Status = updateMeetingAgenda.Status; _iMSDbContext.MeetingAgendas.Update(meetingAgenda); await _iMSDbContext.SaveChangesAsync(); return(new SharedLookUpResponse() { HasError = false, Message = "Meeting Agenda updated successfully" }); } }