Esempio n. 1
0
        public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            var userToCheck = _userService.GetByMail(userForRegisterDto.Email);

            if (userToCheck == null)
            {
                byte[] passwordHash, passwordSalt;
                HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
                var user = new User
                {
                    Email        = userForRegisterDto.Email,
                    FirstName    = userForRegisterDto.FirstName,
                    LastName     = userForRegisterDto.LastName,
                    PasswordHash = passwordHash,
                    PasswordSalt = passwordSalt,
                    Status       = true
                };
                _userService.Add(user);
                var user1    = _userService.GetByMail(user.Email);
                var customer = new Customer {
                    UserId = user1.Id, CompanyName = $"{user1.FirstName} {user1.LastName}"
                };
                _customerService.Add(customer);
                var userFindex = new UserFindex {
                    UserId = user1.Id
                };
                _findexService.Add(userFindex);
                var userOperationClaim = new UserOperationClaim {
                    UserId = user1.Id
                };
                _claimService.Add(userOperationClaim);
                return(new SuccessDataResult <User>(user, Messages.UserRegistered));
            }
            return(new ErrorDataResult <User>(Messages.UserAlreadyExists));
        }
Esempio n. 2
0
        public IDataResult <User> JobGiverRegister(UserForRegisterDto userForRegisterDto)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(userForRegisterDto.Password, out passwordHash, out passwordSalt);
            _unitOfWork.BeginTransaction();
            try
            {
                var user = new User
                {
                    Email        = userForRegisterDto.Email,
                    FirstName    = userForRegisterDto.FirstName,
                    LastName     = userForRegisterDto.LastName,
                    PasswordHash = passwordHash,
                    PasswordSalt = passwordSalt,
                    Status       = true
                };
                _unitOfWork.userDal.Add(user);
                _unitOfWork.Save();

                var userClaim = new UserOperationClaim
                {
                    UserId           = user.Id,
                    OperationClaimId = (int)EnumOperationClaims.Is_Veren
                };
                _unitOfWork.userOperationClaimDal.Add(userClaim);
                _unitOfWork.Save();
                _unitOfWork.Commit();
                return(new SuccessDataResult <User>(user, Messages.UserRegistered));
            }
            catch (Exception)
            {
                _unitOfWork.Rollback();
                return(new ErrorDataResult <User>(Messages.UserRegistered));
            }
        }
Esempio n. 3
0
        public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var user = new User
            {
                Email        = userForRegisterDto.Email,
                FirstName    = userForRegisterDto.FirstName,
                LastName     = userForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };

            _userService.Add(user);

            var uoc = new UserOperationClaim
            {
                UserId           = user.Id,
                OperationClaimId = userForRegisterDto.ClaimId
            };

            _userOperationClaimService.Add(uoc);
            return(new SuccessDataResult <User>(user, "Kayıt olundu"));
        }
Esempio n. 4
0
 public void AddUserClaim(UserOperationClaim entity)
 {
     using (var context = new CoindayDBContext())
     {
         context.Entry(entity).State = EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public void AddUserOperationClaim(UserOperationClaim userOperationClaim)
 {
     using (var context = new YazilimYapimiContext())
     {
         context.UserOperationClaims.Add(userOperationClaim);
         context.SaveChanges();
     }
 }
        public async Task <ActionResult> AnonymusRegister(UserForRegisterDto userForRegisterDto)
        {
            var cozen = HttpContext.Session.GetString("uuid");

            if (userForRegisterDto.Email == null || userForRegisterDto.KullaniciAdi == null || userForRegisterDto.ad == null || userForRegisterDto.soyad == null)
            {
                ModelState.AddModelError("kullanicihata", "Lütfen Heryeri Doldurunuz");
                return(RedirectToAction("Index", "Register"));
            }

            var hasKullaniciAdi = _context.Users.Where(u => u.KullaniciAdi == userForRegisterDto.KullaniciAdi);

            if (hasKullaniciAdi.Count() != 0)
            {
                ModelState.AddModelError("kullanicihata", "Kullanıcı Adı Bulunmaktadır");
                return(RedirectToAction("Index", "Register"));
            }
            byte[] passwordSalt, passworHash;
            HashingHelper.CreatePasswordHash(userForRegisterDto.password, out passworHash, out passwordSalt);
            var user = new UserdbModel
            {
                KullaniciAdi = userForRegisterDto.KullaniciAdi,
                Email        = userForRegisterDto.Email,
                Ad           = userForRegisterDto.ad,
                Soyad        = userForRegisterDto.soyad,
                SifreHash    = passworHash,
                SifreSalt    = passwordSalt,
                Status       = true
            };

            _context.Users.Add(user);
            _context.SaveChanges();
            var current = _context.Users.Where(u => u.KullaniciAdi == userForRegisterDto.KullaniciAdi).FirstOrDefault();

            UserOperationClaim userOperation = new UserOperationClaim
            {
                UserId           = current.ID,
                OperationClaimId = 2
            };

            _context.UserOperationClaims.Add(userOperation);
            _context.SaveChanges();
            var result = _context.Users.Where(u => u.KullaniciAdi == user.KullaniciAdi) as UserdbModel;

            HttpContext.Session.SetString("username", user.KullaniciAdi);
            _jwtHelper = new JwtHelper(Configuration);
            var claims = _efUser.GetClaims(user);
            var token  = _jwtHelper.CreateToken(user, claims);

            HttpContext.Session.SetString("JWToken", token.Token);

            _context.CozulenTest.Where(c => c.cozen == cozen).FirstOrDefault().cozen = user.KullaniciAdi;
            _context.Istatistik.Where(c => c.cozen == cozen).FirstOrDefault().cozen  = user.KullaniciAdi;
            _context.SaveChanges();
            HttpContext.Session.Remove("uuid");

            return(RedirectToAction("GetTest", "Test"));
        }
Esempio n. 7
0
        public IResult Update(UserOperationClaim userOperationClaim)
        {
            var claim = GetClaimByUserId(userOperationClaim.UserId).Data;

            claim.UserId           = userOperationClaim.UserId;
            claim.OperationClaimId = userOperationClaim.OperationClaimId;
            _userOperationClaimDal.Update(claim);
            return(new SuccessResult(Messages.UserOperationClaimAdded));
        }
        public IResult Add(UserOperationClaim entity)
        {
            var claim = new UserOperationClaim {
                UserId = entity.UserId, OperationClaimId = 2006
            };

            _userOperationClaimsDal.Add(claim);
            return(new SuccessResult());
        }
        public IActionResult DeleteClaim(UserOperationClaim user)
        {
            var result = _userService.DeleteClaim(user);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result.Message));
        }
Esempio n. 10
0
        public async Task <IResult> AddUserClaim(User user)
        {
            var operationClaim     = (await _operationClaimService.GetByName("user")).Data;
            var userOperationClaim = new UserOperationClaim {
                OperationClaimId = operationClaim.Id, UserId = user.Id
            };
            await _userOperationClaimDal.AddAsync(userOperationClaim);

            return(new SuccessResult(Messages.UserOperationClaimAdded));
        }
        public IActionResult Add(UserOperationClaim userOperationClaim)
        {
            var result = _claimsService.Add(userOperationClaim);

            if (result.Success)
            {
                return(Ok(result.Message));
            }
            return(BadRequest(result));
        }
        private IResult CheckIfDefaultOperation(UserOperationClaim userOperationClaim)
        {
            int userClaim = 2;

            if (userOperationClaim.OperationClaimId == userClaim)
            {
                return(new ErrorResult());
            }
            return(new SuccessResult());
        }
        public IResult AddUserClaim(User user)
        {
            var operationClaim     = _operationClaimService.GetByName("user").Data;
            var userOperationClaim = new UserOperationClaim {
                OperationClaimId = operationClaim.Id, UserId = user.UserId
            };

            _userOperationClaimDal.Add(userOperationClaim);
            return(new SuccessResult(Messages.Successed));
        }
Esempio n. 14
0
        public IActionResult AddUserOperaitonClaim(UserOperationClaim userOperationClaim)
        {
            var result = _userOperationClaimService.Add(userOperationClaim);

            if (!result.Success)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Esempio n. 15
0
        public IActionResult Update(UserOperationClaim operation)
        {
            var result = _uOperationService.Update(operation);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public ActionResult Delete(UserOperationClaim userOperationClaim)
        {
            var result = _userOperationClaimService.Delete(userOperationClaim);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public ActionResult Add(UserOperationClaim claiming)
        {
            var result = claim.Add(claiming);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IActionResult Update(UserOperationClaim userOperationClaim)
        {
            var result = _userOperationClaim.Update(userOperationClaim);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IResult Delete(UserOperationClaim userOperationClaim)
        {
            var result = BusinessRules.Run(CheckIfDefaultOperation(userOperationClaim));

            if (result == null)
            {
                _userOperationClaimDal.Delete(userOperationClaim);
                return(new SuccessResult(Messages.Successful));
            }
            return(new ErrorResult(Messages.ClaimCantDelete));
        }
        public IActionResult Update([FromForm(Name = ("userOperationClaim"))] UserOperationClaim userOperationClaim)
        {
            var result = _userOperationClaimService.Update(userOperationClaim);

            if (result.Succcess)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Esempio n. 21
0
        public IResult Add(UserOperationClaim userOperationClaim)
        {
            var result = _userOperaitonClaimDal.GetAll(u => u.UserId == userOperationClaim.UserId && u.OperationClaimId == userOperationClaim.OperationClaimId);

            if (result.Count != 0)
            {
                return(new ErrorResult(Messages.UserOperationClaimAlreadyExist));
            }
            _userOperaitonClaimDal.Add(userOperationClaim);
            return(new SuccessResult(Messages.ListedUserOperationClaims));
        }
        public IResult Add(UserOperationClaim userOperationClaim)
        {
            var result = BusinessRules.Run(CheckClaimExists(userOperationClaim));

            if (result != null)
            {
                return(new ErrorResult(result.Message));
            }
            _userOperationClaimDal.Add(userOperationClaim);
            return(new SuccessResult());
        }
Esempio n. 23
0
        public IResult AddUser(User user)
        {
            UserOperationClaim claim = new UserOperationClaim()
            {
                OperationClaimId = 1002,
                UserId           = user.UserId
            };

            _claimDal.Add(claim);
            return(new SuccessResult(Messages.AddClaim));
        }
        public IResult Update(UserOperationClaim userOperationClaim)
        {
            IResult result = BusinessRules.Run(CheckUserHasOperationClaim(userOperationClaim));

            if (result != null)
            {
                return(result);
            }
            _userOperationClaimDal.Update(userOperationClaim);
            return(new SuccessResult(Messages.UserOperationClaimUpdated));
        }
        public IResult Add(UserOperationClaim userOperationClaim)
        {
            var result = BusinessRules.Run(CheckIfClaimExist(userOperationClaim));

            if (result == null)
            {
                _userOperationClaimDal.Add(userOperationClaim);
                return(new SuccessResult(Messages.Successful));
            }
            return(new ErrorResult(Messages.ClaimAlreadyExist));
        }
        //[ValidationAspect(typeof(UserOperationClaimValidator))]
        public IResult Add(UserOperationClaim entity)
        {
            var result = BusinessRules.Run(CheckUserOperationClaimCount());

            if (result != null)
            {
                return(result);
            }
            _userDal.Add(entity);
            return(new SuccessResult(Messages.Added));
        }
Esempio n. 27
0
        public IResult PostClaim(UserOperationClaim user)
        {
            IResult result = BusinessRules.Run(IfUserAlreadyHaveClaim(user.Id));

            if (result != null)
            {
                return(result);
            }
            userDal.AddClaim(user);
            return(new SuccessResult(Messages.UserClaimUpdated));
        }
        public IActionResult GetAll(UserOperationClaim userOperationClaim)
        {
            var result = _userOperationClaimService.GetAll();

            if (result.Success == true)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Esempio n. 29
0
        public IResult AddUserDefaultClaim(UserForRegisterDto userForRegisterDto)
        {
            var user = _userService.GetByMail(userForRegisterDto.Email);
            var data = new UserOperationClaim()
            {
                ClaimId = 1,
                UserId  = user.Data.Id
            };

            _userService.AddUserClaim(data);
            return(new SuccessResult(Messages.ClaimAdded));
        }
Esempio n. 30
0
        public IResult Add(User user)
        {
            _userDal.Add(user);
            UserOperationClaim claim = new UserOperationClaim()
            {
                UserID           = user.ID,
                OperationClaimID = _userDal.GetClaim("User").ID
            };

            _userDal.AddUserOperationClaim(claim);
            return(new SuccessResult("Kayıt Başarılı"));
        }