public async Task <AnnouncePhotoForReturnDto> CreateForPublic(FileUploadDto uploadDto) { var checkAnnounceById = await announceDal.GetAsync(x => x.Id == uploadDto.AnnounceId); var claimId = int.Parse(httpContextAccessor.HttpContext.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value); if (claimId != checkAnnounceById.UserId) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.OperationDenied }); } if (checkAnnounceById == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFoundAnnounce }); } if (checkAnnounceById.ContentType.ToLower() != uploadDto.FileType.ToLower()) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = "Lütfen duyuru tipine uygun bir dosya yükleyin" }); } var uploadFile = new UploadedFileResultDto(); if (uploadDto.FileType.ToLower() == "image") { uploadFile = await upload.Upload(uploadDto.File, "announce"); } if (uploadDto.FileType.ToLower() == "video") { uploadFile = await upload.UploadVideo(uploadDto.File, "announce"); } var mapForCreate = new AnnouncePhotoForCretionDto(); mapForCreate.Name = uploadFile.Name; mapForCreate.FullPath = uploadFile.FullPath; mapForCreate.AnnounceId = uploadDto.AnnounceId; mapForCreate.FileType = uploadFile.FileType; mapForCreate.Duration = uploadDto.Duration; mapForCreate.IsConfirm = false; mapForCreate.UnConfirm = false; var mapForDb = mapper.Map <AnnouncePhoto>(mapForCreate); var createPhoto = await announcePhotoDal.Add(mapForDb); //Make Announce IsNew True checkAnnounceById.IsNew = true; checkAnnounceById.IsPublish = false; checkAnnounceById.Reject = false; await announceDal.Update(checkAnnounceById); return(mapper.Map <AnnouncePhoto, AnnouncePhotoForReturnDto>(createPhoto)); }
public async Task <AnnouncePhotoForReturnDto> Update(AnnouncePhotoForCretionDto updateDto) { var checkByIdFromRepo = await announcePhotoDal.GetAsync(x => x.Id == updateDto.Id); if (checkByIdFromRepo == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } var mapForUpdate = mapper.Map(updateDto, checkByIdFromRepo); var updatePhoto = await announcePhotoDal.Update(mapForUpdate); return(mapper.Map <AnnouncePhoto, AnnouncePhotoForReturnDto>(updatePhoto)); }
public async Task <AnnouncePhotoForReturnDto> Update(AnnouncePhotoForCretionDto creationDto) { var photo = await announcePhotoService.Update(creationDto); var connIds = await userTracker.GetOnlineUser(); if (connIds != null && connIds.Length != 0) { await hubContext.Clients.GroupExcept("Announce", connIds).SendAsync("ReceiveNewPhotoAnnounce", photo, "update"); } var onlineScreens = await onlineScreenService.GetAllOnlineScreenConnectionId(); if (onlineScreens != null && onlineScreens.Length != 0) { await kiosksHub.Clients.Clients(onlineScreens).SendAsync("ReloadScreen", true); } return(photo); }
public async Task <AnnouncePhotoForReturnDto> Create(FileUploadDto uploadDto) { var checkAnnounceById = await announceDal.GetAsync(x => x.Id == uploadDto.AnnounceId); if (checkAnnounceById == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFoundAnnounce }); } if (checkAnnounceById.ContentType.ToLower() != uploadDto.FileType.ToLower()) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = "Lütfen duyuru tipine uygun bir dosya yükleyin" }); } var uploadFile = new UploadedFileResultDto(); if (uploadDto.FileType.ToLower() == "image") { uploadFile = await upload.Upload(uploadDto.File, "announce"); } if (uploadDto.FileType.ToLower() == "video") { uploadFile = await upload.UploadVideo(uploadDto.File, "announce"); } var mapForCreate = new AnnouncePhotoForCretionDto(); mapForCreate.Name = uploadFile.Name; mapForCreate.FullPath = uploadFile.FullPath; mapForCreate.AnnounceId = uploadDto.AnnounceId; mapForCreate.FileType = uploadFile.FileType; mapForCreate.Duration = uploadDto.Duration; mapForCreate.IsConfirm = false; mapForCreate.UnConfirm = false; var mapForDb = mapper.Map <AnnouncePhoto>(mapForCreate); var createPhoto = await announcePhotoDal.Add(mapForDb); return(mapper.Map <AnnouncePhoto, AnnouncePhotoForReturnDto>(createPhoto)); }