public UpdateUser (UserDto user) { InitializeComponent (); this.user = user; this.FindByName<Entry>("txt_updateName").Text = user.Name; this.FindByName<Entry>("txt_updateAge").Text = user.Age.ToString(); }
public static void UpdateUser(UserDto userDto) { using(var uow = new UnitOfWork()) { var userDe = uow.UsersRepository.GetUser(userDto.UserId); userDe.Name = userDto.Name; userDe.Age = userDto.Age; uow.Save(); } }
public static void CreateUser(UserDto userDto) { using(var uow = new UnitOfWork()) { var userDe = new Users(); MapUserToDe(userDto,userDe); userDe.AddedOn = DateTime.Now; uow.UsersRepository.Insert(userDe); uow.Save(); } }
void OnAddClick(object sender, EventArgs e){ UserDto user = new UserDto(); int age; bool valid = ValidateUser (Name.Text, Age.Text, out age); if (valid) { user.UserId = Guid.NewGuid(); user.Name = Name.Text; user.Age = age; AddUser (user); } }
public async Task AddUser(UserDto user) { using(var httpClient = CreateClient()){ var json = JsonConvert.SerializeObject (user); var content = new StringContent (json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await httpClient.PostAsync (string.Format("values/{0}/new", user.UserId), content); if (response != null && response.IsSuccessStatusCode) { PopulateGrid (); notificator = DependencyService.Get<IToastNotificator> (); await notificator.Notify (ToastNotificationType.Info, "User added", null, new TimeSpan (0, 0, 3)); } } }
private static void MapUserToDe(UserDto userDto, Users userDe) { userDe.UserID = userDto.UserId; userDe.Name = userDto.Name; userDe.Age = userDto.Age; }