/// <summary> /// Method to add religion - SS /// </summary> /// <param name="name">name of religion</param> /// <param name="instituteId">institute id</param> /// <returns>message</returns> public async Task <SharedLookUpResponse> AddReligionAsync(AddReligionManagementAc addReligion, int instituteId) { if (!await _iMSDbContext.Religions.AnyAsync(x => x.InstituteId == instituteId && x.Code.ToLowerInvariant() == addReligion.Code.ToLowerInvariant())) { var religion = new Religion() { CreatedOn = DateTime.UtcNow, InstituteId = instituteId, Name = addReligion.Name, Code = addReligion.Code, Description = addReligion.Description, Status = true }; _iMSDbContext.Religions.Add(religion); await _iMSDbContext.SaveChangesAsync(); return(new SharedLookUpResponse() { HasError = false, Message = "Religion added successfully" }); } else { return new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Religion with the same code is already exist" } }; }
public async Task <IActionResult> AddReligionAsync([FromBody] AddReligionManagementAc addReligionManagement) { if (string.IsNullOrEmpty(addReligionManagement.Name.Trim())) { return(Ok(new SharedLookUpResponse { HasError = true, ErrorType = SharedLookUpResponseType.Name, Message = "Religion name can't be empty" })); } else if (string.IsNullOrEmpty(addReligionManagement.Name.Trim())) { return(Ok(new SharedLookUpResponse { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Religion code can't be empty" })); } else { var loggedInUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync(); return(Ok(await _religionManagementRepository.AddReligionAsync(addReligionManagement, loggedInUserInstituteId))); } }