public IActionResult Post([FromForm] ChannelForAddDto channelForAddDto) { var resultId = User.Claims.GetUserId(); IResult checkResult = _channelService.CheckIfChannelNameExists(channelForAddDto.Name); if (!checkResult.IsSuccessful) { return(BadRequest(checkResult.Message)); } if (channelForAddDto.File.Length > 0) { ImageUploadResult imageUploadResult = _photoUpload.ImageUpload(channelForAddDto.File); if ((int)imageUploadResult.StatusCode < 300) { var channel = _mapper.Map <Channel>(channelForAddDto); channel.ChannelPhotoUrl = imageUploadResult.Uri.ToString(); channel.PublicId = imageUploadResult.PublicId; channel.UserId = resultId.Data; IResult result = _channelService.Add(channel); if (result.IsSuccessful) { var mapResult = _mapper.Map <ChannelForDetailDto>(channel); this.RemoveCacheByContains(resultId.Data + "/user-channels"); return(Ok(mapResult)); } return(BadRequest(result.Message)); } return(BadRequest(imageUploadResult.Error.Message)); } return(BadRequest()); }
public IActionResult Add([FromBody] ChannelDto channelDto) { var result = _channelService.Add(channelDto); return(result.Success ? Ok(result.Message) : BadRequest(result.Message)); }
public async Task Create(Channel channel) { await _channelService.Add(channel); var channels = await _channelService.Get(); await _hubContext.Clients.All.ChannelListUpdated(channels); }
public async Task <IActionResult> Post([FromBody] FeedChannelViewModel channel) { var user = await _userService.GetCurrentUser(); var channelEntity = channel.ToEntity(); channelEntity.UserId = user.Id; await _channelService.Add(channelEntity); return(Ok()); }
public IActionResult Add(Channel channel) { var result = _channelService.Add(channel); if (result.Succcess) { return(Ok(result)); } return(BadRequest(result)); }
public RootMutation( IQuoteService quoteService, IChannelService channelService, IIdentityService identityService) { Name = "Mutation"; Field <UserType>( "createUser", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "username" }, new QueryArgument <StringGraphType> { Name = "password" }), resolve: context => { var userName = context.GetArgument <string>("username"); var password = context.GetArgument <string>("password"); var user = identityService.CreateIdentity(userName, password).Result; return(user); }); Field <QuoteType>( "createQuote", arguments: new QueryArguments(new QueryArgument <QuoteInputType> { Name = "input" }), resolve: context => { var quote = context.GetArgument <Quote>("input"); return(quoteService.Add(quote)); }); Field <ChannelType>( "createChannel", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "title" }), resolve: context => { var title = context.GetArgument <string>("title"); return(channelService.Add(new Channel { Title = title })); }); }
public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password) { HashingHelper.CreatepasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt); var user = new User { FirstName = userForRegisterDto.FirstName, LastName = userForRegisterDto.LastName, Email = userForRegisterDto.Email, PasswordHash = passwordHash, //Buradaki PasswordHash Ve PasswordSalt yukarıda Hashhing Helper da out keywordleri PasswordSalt = passwordSalt, //ile verlilen passwordsalt ve password hash. out keyword ü ile verilen obje geriye döndürülür. Status = true //Şimdilik direkt olarak onay verildi.Daha sonra EMail Onay Modülü Eklenecek. }; _userService.Add(user); var communication = new Communication { UserId = user.Id, Address1 = userForRegisterDto.Address1, Address2 = userForRegisterDto.Address2, City = userForRegisterDto.City, Continent = userForRegisterDto.Continent, Country = userForRegisterDto.Country, PhoneNumber = userForRegisterDto.PhoneNumber, Street = userForRegisterDto.Street, ZipCode = userForRegisterDto.ZipCode, }; _communicationService.Add(communication); var userDetail = new UserDetail { UserId = user.Id, DateOfBorn = userForRegisterDto.DateOfBorn, DateOfJoin = DateTime.Now,//Direkt kayıt olduğu zaman atanacak Gender = userForRegisterDto.Gender, IdentityNumber = userForRegisterDto.IdentityNumber, RecoveryEmail = userForRegisterDto.RecoveryEmail, PhotoPath = "DefaultPhoto" }; _userDetailService.Add(userDetail); var channel = new Channel { UserId = user.Id, ChannelName = $"{user.FirstName} {user.LastName}", InstallationDate = userDetail.DateOfJoin, ChannelPhotoPath = "defaultPhoto", Description = $"This Channel Owner Name is {user.FirstName} {user.LastName}.This Channel Build on {userDetail.DateOfJoin}", UpdateDate = DateTime.Now }; _channelService.Add(channel); //Register olduktan sonra kullanıcıya default olarak operationClaim.ClaimType da Default olarak belirtilen //ilk claim atanıyor. var userOperationClaim = new UserOperationClaim { UserId = user.Id, OperationClaimId = _operationClaimService.GetDefaultClaims("Default").Data[0].Id }; _userOperationClaimService.Add(userOperationClaim); return(new SuccessDataResult <User>(user)); }