public void Create(Profile profile) { if (profile.UserID == 0) { throw new Exception("Can't create a profile not associated with a valid UserID"); } _profileRepository.Create(profile); }
public ResponseMessage <User> Create(RegisterUserRequest data) { //TODO: RegisterUserRequest beletenni minden olyan tulajdonsagot ami szukseges a User es a Profile objektumok letrehozasara ResponseMessage <User> response = new ResponseMessage <User>(); try { User user = new User(data); user.Password = PasswordHasher.Create(data.Password, data.Email); user.PublicID = UniqKeyGenerator.Generate(); response.ResponseObject = _userRepository.Create(user); Profile profile = data.ConvertTo <Profile>(); profile.ID = user.PublicID; _profileRepository.Create(profile); response.IsSuccess = true; response.ErrorMessage = "Success"; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
public async Task <IActionResult> CreateOneProfile([FromBody] NewProfileDto createdProfile) { var profileToAdd = _mapper.Map <Data.Models.Profile>(createdProfile); profileToAdd.Id = Guid.NewGuid(); var userId = User.Claims.FirstOrDefault(x => x.Type == "userId").Value; profileToAdd.UserId = Guid.Parse(userId); profileToAdd.CreatedOn = DateTime.Now; _profileRepository.Create(profileToAdd); if (!await _profileRepository.SaveAsync()) { var errMsg = "Error creating a profile"; _logger.Error(errMsg); var err = new ErrorObject() { Method = "POST", At = "/api/profiles", StatusCode = 500, Error = errMsg }; return(StatusCode(500, err)); } return(CreatedAtAction(nameof(GetOneProfile), new { id = profileToAdd.Id }, profileToAdd)); }
private Profile CreateProfile(string userName, string passWord, string description, string firstName, string lastName) { //Opret login information Credential credential = (string.IsNullOrWhiteSpace(firstName) && string.IsNullOrWhiteSpace(lastName)) ? CredentialService.Create(userName, passWord) : CredentialService.Create(userName, passWord, firstName, lastName); //Opret profil Profile profile = new Profile() { CredentialsId = credential.CredentialsId, Description = description }; //Tilføj grunkers profile.Grunkers.Add(new Grunker { Sum = 1500 }); //Tikføj aktivitet til profilen profile.ProfileActivities.Add(new ProfileActivity(GetActivityByName("Created").ActivityTypeId)); //Gem i databasen ProfileRepository.Create(profile); return(profile); }
public IActionResult Create([FromBody] Profile profile) { if (profile == null) { return(BadRequest()); } _repository.Create(profile); return(Ok()); }
public async Task <Unit> Handle(BindProfileCommand request, CancellationToken cancellationToken) { Profile profile = new Profile() { RoleId = request.RoleId, UserId = request.UserId }; await profileRepository.Create(profile, cancellationToken); return(Unit.Value); }
public async Task CreateProfile(ProfileRequest request) { var profile = new Profile { Id = new Guid(), AvatarUrl = request.AvatarUrl ?? "", FavoriteSpot = request.FavoriteSpot ?? null, Tribes = request.Tribes ?? null, UserName = request.UserName, }; await _repository.Create(profile); }
public async Task <IActionResult> PostProfile([FromBody] Profile profile) { try { var id = await _repo.Create(profile); return(CreatedAtAction(nameof(GetProfile), new { id })); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e)); } }
public void CreateUser(UserEntity user) { var role = roleRepository.GetById(user.RoleEntities.ToList()[0].Id).ToBllRole(); user.RoleEntities = new HashSet <RoleEntity>(); userRepository.Create(user.ToDalUser()); uow.Commit(); var dalUser = userRepository.GetByPredicate(x => x.Email == user.Email); userRepository.AddRoleToUser(role.ToDalRole(), dalUser); profileRepository.Create(new DalProfile() { Id = dalUser.Id, ImageUrl = "http://res.cloudinary.com/djb7hr8nk/image/upload/v1466780959/empty_zeehdh.png" }); uow.Commit(); }
public async Task <Profile> Post(IFormFile file, ProfileDto profileDto) { try { await validPostProfile(profileDto); await new ImageUploadHandler(_environment).Save(file, profileDto); var profile = Profile.Factory.Create(profileDto); await _profileRepository.Create(profile); return(profile); } catch (Exception e) { throw e; } }
public ResponseMessage <bool> Create(Profile entity) { ResponseMessage <bool> response = new ResponseMessage <bool>(); try { response.ResponseObject = _profileRepository.Create(entity); response.IsSuccess = true; response.ErrorMessage = "Success"; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
public async Task <IActionResult> Register([FromBody] RegisterBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newProfile = _profileRepository.Create(); var newUser = _userRepository.Create(model.UserName, model.Password, newProfile); _employeeRepository.Create(newUser.Id); await _systemContext.SaveChangesAsync(); await _domainContext.SaveChangesAsync(); return(Ok()); }
public ActionResult Add(ProfileRegisterModel profileRegistered) { var title = ""; string content; var profile = Mapper.Map <ProfileRegisterModel, Profile>(profileRegistered); try { if (profileRegistered.UploadPhoto != null) { WebImage img = new WebImage(profileRegistered.UploadPhoto.InputStream); if (img.Width > 200 || img.Height > 200) { img.Resize(200, 200); } profile.Photo = img.GetBytes(); } } catch (Exception) { title = "Error!"; content = "Formato de Imagen Incorrecto"; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage); return(RedirectToAction("Add")); } var query = _profileRepository.Filter(e => e.FullName == profile.FullName); if (query.Any()) { title = "Error!"; content = "El Perfil ya existe."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage); return(RedirectToAction("Index")); } var profileCreated = _profileRepository.Create(profile); title = "Perfil Agregado"; content = profileCreated.FullName + "ha sido guardado exitosamente."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage); return(RedirectToAction("Index")); }
public async Task <IActionResult> CreateOrUpdate(int id, City city) { if (ModelState.IsValid) { if (id == 0) { _cityRepository.Create(city); //return RedirectToAction(nameof(Index)); } else { _cityRepository.Update(city); //return RedirectToAction(nameof(Index)); } return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _cityRepository.GetCities()) })); } return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "CreateOrUpdate", city) })); }
public IActionResult Create(Profile profile, IFormFile file) { profile.UserName = GetUserName(_userManager); profile.UserId = GetUserId(_userManager); profile.ImageUrl = UploadFile2(file); var s = _profileRepository.CheckIfExists(x => x.UserName.Equals(profile.UserName)); if (!s) { _profileRepository.Create(profile); } else { return(Content("You Have Already Created Your Profile")); } return(RedirectToAction(nameof(Index))); }
public async Task <CreateProfileCommandResult> Handle(CreateProfileCommand command, CancellationToken cancellationToken) { var profile = _mapper.Map <Domain.DataModels.Profile>(command); profile.Id = Guid.NewGuid(); var response = await _profileRepository.Create(profile); if (response) { return(new CreateProfileCommandResult() { Payload = _mapper.Map <ProfileDto>(profile) }); } else { return(new CreateProfileCommandResult() { Payload = null }); } }
public async Task <Profile> CreateProfile(Profile createProfile) { if (await _profileRepository.UserIdExists(createProfile.UserId)) { throw new InvalidProfile("User already exists"); } if (string.IsNullOrEmpty(createProfile.ProfilePictureUrl)) { using (var md5 = MD5.Create()) { var result = md5.ComputeHash(Encoding.ASCII.GetBytes(createProfile.UserId)); createProfile.ProfilePictureUrl = "https://www.gravatar.com/avatar/" + BitConverter.ToString(result).Replace("-", "" + "").ToLower() + "?s=256&d=identicon&r=PG"; } } var profile = await _profileRepository.Create(createProfile); try { var user = await _client.GetUserAsync(createProfile.UserId); if (user == null) { throw new UserNotFound(); } } catch (UserNotFound) { await _profileRepository.Remove(profile.Id); throw new InvalidProfile("User not found"); } return(profile); }
public ResponseMessage <User> Create(RegisterUserRequest data) { ResponseMessage <User> response = new ResponseMessage <User>(); try { //check if the user exists bool exist = _userRepository.FindEmail(data.Email); //if exist throw exeption if (exist == true) { throw new Exception($"{data.Email} already taken!"); } User user = new User(data); user.Password = PasswordHasher.Create(data.Password, data.Email); user.PublicID = UniqKeyGenerator.Generate(); user.Role = UserRole.User.ToString(); data.Role = UserRole.User.ToString(); response.ResponseObject = _userRepository.Create(user); //create the profile Profile profile = new Profile(user.PublicID, data); response.IsSuccess = _profileRepository.Create(profile); //SendWelcomeEmail(user.Email); } catch (Exception ex) { response.ErrorMessage = ex.Message; response.IsSuccess = false; } return(response); }
public void CreateProfile(ProfileEntity profile) { profileRepository.Create(profile.ToDalProfile()); uow.Commit(); }
public void Create(Profile profile) { _profileRepository.Create(profile); }
public Profile Create([FromBody] Profile profile) { var data = _profileRepository.Create(profile); return(data); }
/// <summary> /// Creates a profile /// </summary> /// <param name="entity">Profile</param> public void Create(BllProfile entity) { profileRepository.Create(entity.ToDalProfile()); unitOfWork.Commit(); }
public void CreateProfile(ProfileManagementModel profile) { _profileRepository.Create(profile); }
public void SetProfiles(string jsonData) { var profiles = JsonSerializer.Deserialize<List<Profile>>(jsonData); _repository.Create(profiles); }
public async Task Create(Profile profile) { await _profileRepository.Create(profile); }
public void Create(Profile profile) { _repo.Create(profile); }
public async Task <int?> CreateProfile(ProfileDTO profile, CancellationToken cancellationToken) { return(await _repository.Create(_mapper.Map <Profile>(profile), cancellationToken)); }
public Profile CreateProfile(Profile profile) { return(_profileRepository.Create(profile)); }