public Reply UpdateUser([FromBody] UserRequest request) { Reply reply = new Reply(); string token = GetToken(); if (userService.VerifyRol(token) != 2 && userService.VerifyRol(token) != 3) { reply.message = "No esta autorizado"; return(reply); } try { int user_id = userService.GetId(token); User user = userService.FindById(user_id); user.description = request.description; user.lastname = request.lastname; user.name = request.name; user.password = request.password; user.image = request.image; userService.Update(user); int n = request.languages.Count(); List <User_wish> lst = userwishService.FindByUser(user_id); int m = lst.Count(); for (int j = 0; j < m; j++) { userwishService.Delete(lst[j]); } for (int i = 0; i < n; i++) { User_wish userwish = new User_wish(); userwish.user_id = user_id; userwish.language_id = request.languages[i]; userwish.level_id = request.levels[i]; userwish.wish_id = request.wishes[i]; userwishService.Save(userwish); } reply.message = "Idiomas actualizados"; } catch (Exception) { throw; } return(reply); }
public bool Delete(User_wish t) { bool flag = true; try { context.User_wish.Remove(t); flag = true; } catch (Exception) { throw; } return(flag); }
public bool Update(User_wish t) { bool flag = false; try { context.Entry(t).State = EntityState.Modified; context.SaveChanges(); flag = true; } catch (Exception exception) { Console.WriteLine(exception.Message.ToString()); } return(flag); }
public bool Update(User_wish t) { throw new NotImplementedException(); }
public bool Save(User_wish t) { return(userWishRepo.Save(t)); }
public bool Delete(User_wish t) { return(userWishRepo.Delete(t)); }
public Reply SignUp([FromBody] SignUpRequest request) { Reply reply = new Reply(); User user = new User(); bool exists; try { exists = userService.ExitsEmail(request.email); if (exists) { reply.result = 409; reply.message = "El email ya se encuentra registrado"; } else { #region User's request user.name = request.name; user.lastname = request.lastname; user.active = 1; user.birthday = request.birthday; user.country_id = request.country; user.description = request.description; user.email = request.email; user.gender = request.gender; user.mobilephone = request.mobilephone; user.password = request.password; user.rol_id = 3; user.token = ""; user.image = request.image; #endregion userService.Save(user); #region Union with Language int n = request.languages.Count(); user = userService.FindByEmail(request.email); for (int i = 0; i < n; i++) { User_wish userwish = new User_wish(); userwish.user_id = user.id; userwish.language_id = request.languages[i]; userwish.level_id = request.levels[i]; userwish.wish_id = request.wishes[i]; userwishService.Save(userwish); } #endregion reply.result = 200; reply.message = "registro exitoso"; } } catch (Exception exception) { reply.result = 500; reply.message = "Ocurrio un error" + exception.Message.ToString(); } return(reply); }