public async Task <IActionResult> CreateAmazonAccount(int id)
        {
            var username     = ApplicationUtility.GetTokenAttribute(Request.Headers["Authorization"], "sub");
            var service      = new InstituteRepositoryService(connString);
            var institute    = (await service.GetInstituteById(id)).Name;
            var bucketSevice = new AmazonS3Service();
            var bucketName   = GetName(institute);
            await bucketSevice.CreateBucketToS3(bucketName);

            var iamService   = new AmazonIAMService();
            var iamUserName  = GetName(institute);
            var accesKeyInfo = await iamService.CreateIAMUser("/", iamUserName);

            var amazonAccountModel = new InstituteAmazonAccount()
            {
                AccessKey   = accesKeyInfo.AccessKey,
                Actor       = username,
                BucketName  = bucketName,
                IamUsername = iamUserName,
                InstituteId = id,
                SecretKey   = accesKeyInfo.SecurityKey
            };
            await service.CreateInstituteAmazonAccount(amazonAccountModel);

            var response = new GenericResponse <string>()
            {
                IsSuccess    = true,
                Message      = "Cloud account created successfully.",
                ResponseCode = 200,
                Result       = "Success"
            };

            return(Ok(response));
        }
        public async Task <IActionResult> Get(int id)
        {
            var service = new InstituteRepositoryService(connString);
            var result  = await service.GetInstituteById(id);

            var response = new GenericResponse <InstituteDTO>()
            {
                IsSuccess    = true,
                Message      = "Data fetched successfully.",
                ResponseCode = 200,
                Result       = result
            };

            return(Ok(response));
        }
        public async Task <IActionResult> GetInstitutesByName(string name)
        {
            var service = new InstituteRepositoryService(connString);
            var result  = await service.GetAllInstitutesByName(name);

            var response = new GenericResponse <List <InstituteDTO> >()
            {
                IsSuccess    = true,
                Message      = "Data fetched successfully.",
                ResponseCode = 200,
                Result       = result
            };

            return(Ok(response));
        }
        public async Task <IActionResult> CheckDuplicate(InstitutionDuplicateModel model)
        {
            var service = new InstituteRepositoryService(connString);
            var res     = await service.GetInstitutesByNameBranchName(model.Name, model.BranchName);

            bool result   = res.Count > 0;
            var  response = new GenericResponse <bool>()
            {
                IsSuccess    = true,
                Message      = "Data fetched successfully.",
                ResponseCode = 200,
                Result       = result
            };

            return(Ok(response));
        }
        public async Task <IActionResult> Put(int id, InstitutionModelUpdate model)
        {
            var username = ApplicationUtility.GetTokenAttribute(Request.Headers["Authorization"], "sub");

            model.Actor = username;
            var service = new InstituteRepositoryService(connString);
            await service.UpdateInstitute(model, id);

            var response = new GenericResponse <string>()
            {
                IsSuccess    = true,
                Message      = "Institute updated successfully.",
                ResponseCode = 200,
                Result       = "Success"
            };

            return(Ok(response));
        }