/// <summary> /// Method to add currency - SS /// </summary> /// <param name="addAdministrationCurrency">currency detail</param> /// <param name="instituteId">institute id</param> /// <returns>message</returns> public async Task <SharedLookUpResponse> AddAdministrationCurrencyAsync(AddAdministrationCurrencyAc addAdministrationCurrency, int instituteId) { if (await _iMSDbContext.AdministrationCurrencies.AnyAsync(x => x.Symbol.ToLowerInvariant() == addAdministrationCurrency.Code.ToLowerInvariant() && x.InstituteId == instituteId)) { return new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Currency with the same symbol is already exist" } } ; else { var currency = new AdministrationCurrency() { CreatedOn = DateTime.UtcNow, CurrencyName = addAdministrationCurrency.Name, InstituteId = instituteId, Symbol = addAdministrationCurrency.Code, Description = addAdministrationCurrency.Description, Status = true }; _iMSDbContext.AdministrationCurrencies.Add(currency); await _iMSDbContext.SaveChangesAsync(); return(new SharedLookUpResponse() { HasError = false, Message = "Currency added successfully" }); } }
public async Task <IActionResult> AddAdministrationCurrencyAsync([FromBody] AddAdministrationCurrencyAc addAdministrationCurrency) { if (string.IsNullOrEmpty(addAdministrationCurrency.Name.Trim())) { return(Ok(new SharedLookUpResponse { ErrorType = SharedLookUpResponseType.Name, HasError = true, Message = "Currency name can't be null or empty" })); } else if (string.IsNullOrEmpty(addAdministrationCurrency.Code.Trim())) { return(Ok(new SharedLookUpResponse { ErrorType = SharedLookUpResponseType.Code, HasError = true, Message = "Currency symbol can't be null or empty" })); } else { var loggedInUserInstituteId = await GetUserCurrentSelectedInstituteIdAsync(); return(Ok(await _administrationCurrencyManagementRepository.AddAdministrationCurrencyAsync(addAdministrationCurrency, loggedInUserInstituteId))); } }