/// <summary>
        /// Create a new Institution
        /// </summary>
        /// <param name="requestDTO">Request payload</param>
        /// <returns></returns>
        public async Task <IActionResult> CreateNewInstitution([FromBody] InstitutionRequestDTO requestDTO)
        {
            var result = await _institutionService.CreateAsync(requestDTO);

            if (result != null)
            {
                await DeleteCache("getAllInstitution", cacheName);
            }
            return(new OkObjectResult(new { result }));
        }
        public async Task <IActionResult> UpdateInstitution(Guid Id, [FromBody] InstitutionRequestDTO requestDTO)
        {
            await _institutionService.UpdateAsync(Id, requestDTO);

            if (Id != null && Id != Guid.Empty)
            {
                await DeleteCache("getAllInstitution", cacheName);
            }
            return(new OkObjectResult(new { Id }));
        }
Example #3
0
        public async Task <Guid> CreateAsync(InstitutionRequestDTO requestDTO)
        {
            var institution = new Domain.Model.Institution.Institution
            {
                Name         = requestDTO.Name,
                PhoneNumber  = requestDTO.PhoneNumber,
                EmailAddress = requestDTO.EmailAddress,
                Code         = requestDTO.Code
            };

            _repository.Add(institution);
            await _repository.CommitAsync();

            return(institution.Id);
        }
Example #4
0
        public async Task <Guid> UpdateAsync(Guid Id, InstitutionRequestDTO requestDTO)
        {
            var institution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(Id);

            if (institution == null)
            {
                return(Guid.Empty);
            }
            institution.Code         = requestDTO.Code;
            institution.EmailAddress = requestDTO.EmailAddress;
            institution.PhoneNumber  = requestDTO.PhoneNumber;
            institution.Name         = requestDTO.Name;
            institution.Status       = requestDTO.Status;
            _repository.Update(institution);
            await _repository.CommitAsync();

            return(Id);
        }