public async Task <OutputHandler> AddTeamMemberAsync(TeamMembersDTO teamMember) { var outputhandler = await FileHandler.SaveFileFromByte(teamMember.Artwork, teamMember.Filename, FolderName); if (outputhandler.IsErrorOccured) { if (outputhandler.IsErrorKnown) { return(new OutputHandler { IsErrorOccured = true, Message = outputhandler.Message }); } return(new OutputHandler { IsErrorOccured = true, Message = "Something went wrong while the system tried to upload the file" }); } teamMember.ImageUrl = outputhandler.ImageUrl; try { var MappedTeamMember = new AutoMapper <TeamMembersDTO, TeamMember>().MapToObject(teamMember); _teamMemberRepository.CreateEntity(MappedTeamMember); await _teamMemberRepository.SaveChangesAsync(); return(new OutputHandler { IsErrorOccured = false, Message = "TeamMember has been created Successsdfully " }); } catch (Exception ex) { var outputHandler = await FileHandler.DeleteFileFromFolder(teamMember.ImageUrl, FolderName); return(StandardMessages.getExceptionMessage(ex)); } }
public async Task <OutputHandler> CreateTestimony(TestimonyDTO testimonyDTO) { try { var outputhandler = await FileHandler.SaveFileFromByte(testimonyDTO.ImgBytes, testimonyDTO.FileName, FolderName); if (outputhandler.IsErrorOccured) { if (outputhandler.IsErrorKnown) { return(new OutputHandler { IsErrorOccured = true, Message = outputhandler.Message }); } return(new OutputHandler { IsErrorOccured = true, Message = "Something went wrong while the system tried to upload the file" }); } testimonyDTO.ImageUrl = outputhandler.ImageUrl; var mapped = new AutoMapper <TestimonyDTO, Testimony>().MapToObject(testimonyDTO); _testimonyRepository.CreateEntity(mapped); await _testimonyRepository.SaveChangesAsync(); return(new OutputHandler { IsErrorOccured = false, Message = "testimony Created Successfully" }); } catch (Exception ex) { await FileHandler.DeleteFileFromFolder(testimonyDTO.ImageUrl, FolderName); return(StandardMessages.getExceptionMessage(ex)); } }
public async Task <OutputHandler> AddResourceAsync(ResourceDTO resource) { var outputhandler = await FileHandler.SaveFileFromByte(resource.Artwork, resource.Filename, FolderName); if (outputhandler.IsErrorOccured) { if (outputhandler.IsErrorKnown) { return(new OutputHandler { IsErrorOccured = true, Message = outputhandler.Message }); } return(new OutputHandler { IsErrorOccured = true, Message = "Something went wrong while the system tried to upload the file" }); } resource.ImageUrl = outputhandler.ImageUrl; try { var MappedSermon = new AutoMapper <ResourceDTO, DataAccessLayer.Models.Resource>().MapToObject(resource); _resourceRepository.CreateEntity(MappedSermon); await _resourceRepository.SaveChangesAsync(); return(new OutputHandler { IsErrorOccured = false, Message = "Sermon has been created Successsdfully " }); } catch (Exception ex) { var outputHandler = await FileHandler.DeleteFileFromFolder(resource.ImageUrl, FolderName); return(StandardMessages.getExceptionMessage(ex)); } }
public async Task <OutputHandler> CreateprojectArm(projectArmDTO projectArmDTO) { try { var outputhandler = await FileHandler.SaveFileFromByte(projectArmDTO.ImgBytes, projectArmDTO.Filename, FolderName); if (outputhandler.IsErrorOccured) { if (outputhandler.IsErrorKnown) { return(new OutputHandler { IsErrorOccured = true, Message = outputhandler.Message }); } return(new OutputHandler { IsErrorOccured = true, Message = "Something went wrong while the system tried to upload the file" }); } projectArmDTO.Artwork = outputhandler.ImageUrl; //saving the bytes as string var mapped = new AutoMapper <projectArmDTO, projectArm>().MapToObject(projectArmDTO); _projectArmRepository.CreateEntity(mapped); await _projectArmRepository.SaveChangesAsync(); return(new OutputHandler { IsErrorOccured = false, Message = "project Arm Created Successfully" }); } catch (Exception ex) { var outputHandler = await FileHandler.DeleteFileFromFolder(projectArmDTO.Artwork, FolderName); return(StandardMessages.getExceptionMessage(ex)); } }
public async Task <OutputHandler> CreatePosition(PositionDTO positionDTO) { try { var position = new AutoMapper <PositionDTO, Position>().MapToObject(positionDTO); _positionRepository.CreateEntity(position); await _positionRepository.SaveChangesAsync(); return(new OutputHandler { IsErrorOccured = false, Message = "Position Created Successfully" }); } catch (Exception) { return(new OutputHandler { IsErrorOccured = true, Message = "Something went wrong, Contact Admin" }); } }