public void RegisterUser(UserVm user)
        {
            if (user == null) throw new ArgumentNullException("user");

            var existingUser = _repo.FindBy(x => x.Email.Equals(user.Email)).FirstOrDefault();
            if (existingUser != null) throw new Exception("Korisnik sa datim email-om vec postoji u bazi podataka");

            Mapper.CreateMap<UserVm, User>();

            _repo.Add(Mapper.Map<User>(user));
            _repo.Save();
        }
 public void UpdateUser(Guid userId, UserVm user)
 {
     _repo.Edit(userId, Mapper.Map<User>(user));
     _repo.Save();
 }
        public IHttpActionResult EditUserProfile(UserVm model)
        {
            try
            {
                var user = _userBusinessLogic.GetUserByEmail(model.Email);

                model.Salt = user.Salt;
                model.Password = CalculateHash(user.Salt, model.Password);
                model.Id = user.Id;

                _userBusinessLogic.UpdateUser(user.Id, model);
                return Ok();
            }
            catch (Exception ex)
            {
                return InternalServerError(ex);
            }
        }
        public IHttpActionResult Register(RegisterViewModel model)
        {
            try
            {
                var id = Guid.NewGuid();
                var salt = CreateSalt();

                var user = new UserVm
                {
                    Id = id,
                    Email = model.Email,
                    Name = model.FirstName,
                    LastName = model.LastName,
                    Salt = salt,
                    Password = CalculateHash(salt, model.Password)
                };

                _userBusinessLogic.RegisterUser(user);
                return Ok();
            }
            catch (Exception ex)
            {
                return InternalServerError(ex);
            }
        }