public async Task <HomeAnnounceForKiosksForReturnDto> GetHomeAnnounceByIdAsync(int announceId) { var spec = new HomeAnnounceWithPhotoAndUserSpecification(announceId); var homeannounce = await homeAnnounceDal.GetEntityWithSpecAsync(spec); return(mapper.Map <HomeAnnounce, HomeAnnounceForKiosksForReturnDto>(homeannounce)); }
public async Task <HomeAnnounceForReturnDto> Create(HomeAnnounceForCreationDto creationDto) { var checkByNameFromRepo = await homeAnnounceDal.GetAsync(x => x.Header.ToLower() == creationDto.Header.ToLower()); if (checkByNameFromRepo != null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist }); } var mapForCreate = mapper.Map <HomeAnnounce>(creationDto); var slideId = Guid.NewGuid(); mapForCreate.AnnounceType = "home"; mapForCreate.SlideId = slideId; mapForCreate.Created = DateTime.Now; var createHomeAnnounce = await homeAnnounceDal.Add(mapForCreate); var spec = new HomeAnnounceWithPhotoAndUserSpecification(createHomeAnnounce.Id); var getAnnounceFromRepo = await homeAnnounceDal.GetEntityWithSpecAsync(spec); return(mapper.Map <HomeAnnounce, HomeAnnounceForReturnDto>(getAnnounceFromRepo)); }