Exemplo n.º 1
0
		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();
		}
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
		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);
			}
		}
Exemplo n.º 5
0
		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));
				}
			}
		}
Exemplo n.º 6
0
 private static void MapUserToDe(UserDto userDto, Users userDe) {
     userDe.UserID = userDto.UserId;
     userDe.Name = userDto.Name;
     userDe.Age = userDto.Age;
 }