public UserModelAPI Post(UserModelAPI Task) { UserService objService = new UserService(); var rsp = objService.InsertUserAPI(Task); return(rsp); }
public UserMasterResponse InsertUserAPI(UserModelAPI model) { try { Mapper.CreateMap <UserModelAPI, UserMaster>(); UserMaster objUser = Mapper.Map <UserMaster>(model); if (objUser != null) { Dbcontext.UserMasters.Add(objUser); Dbcontext.SaveChanges(); return(new UserMasterResponse() { response = true }); } else { return(new UserMasterResponse() { response = false }); } } catch (Exception ex) { throw ex; } }
public async Task <string> Login(string email, string pw) { UserModelAPI objUser = new UserModelAPI(); objUser.Email = email; objUser.Password = pw; string obj; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Post, Baseurl + "api/Login"); Req.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(objUser), Encoding.ASCII, "application/json"); var Res = await client.PostAsync(Req.RequestUri, Req.Content); if (Res.IsSuccessStatusCode) { var EmpResponse = Res.Content.ReadAsStringAsync().Result; obj = JsonConvert.DeserializeObject <string>(EmpResponse); return(obj); } } return(null); }
public UserModelAPI Put(UserModelAPI Task) { UserService objService = new UserService(); var rsp = objService.UpdateAPI(Task); return(rsp); }
public UserModel CreateUser(UserModelAPI model) { //get all user List <UserModel> user = TextConnectorProcessor.UserFile.FullFilePath().LoadFile().ConvertToUserModels(); if (user.Where(st => st.CellPhone == model.CellPhone && st.EmailAddress == model.EmailAddress).ToList().Count() > 0) { return(user.Where(st => st.CellPhone == model.CellPhone).FirstOrDefault()); } int currentId = 1; if (user.Count > 0) { currentId = user.OrderByDescending(x => x.Id).First().Id + 1; } UserModel newModel = MapUser.USERApiToDB(model); newModel.Id = currentId; user.Add(newModel); user.SaveToPeopleFile(); //create the address CreateAddress(newModel); CreateBasket(new BasketModel { Time = DateTime.Now, Active = true, OrderBy = newModel }); return(newModel); }
public UserModel Put([FromBody] UserModelAPI userModelAPI) { var user = userService.Login(userModelAPI.Email, userModelAPI.Password); return(user); //if (user == null) // return "Login failed"; //return "Login succesful as " + user.Type; }
public static UserForGeneric USER_API_GENRIC(UserModelAPI model) { return(new UserForGeneric { AuthUserId = model.AuthUserId, FirstName = model.FirstName, LastName = model.LastName, EmailAddress = model.EmailAddress, CellPhone = model.CellPhone }); }
// PUT: api/User/5 public void Put(int id, [FromBody] UserModelAPI userModelAPI) { var user = userService.GetById(id); user.Email = userModelAPI.Email; user.Location = userModelAPI.Location; user.Password = userModelAPI.Password; user.Role = userModelAPI.Role; userService.UpdateUser(user); }
// // GET: /APIUser/ //public ActionResult Index() //{ // return View(); //} public IEnumerable <UserModelAPI> Get(int id) { UserModelAPI objModel = new UserModelAPI(); UserService objService = new UserService(); List <UserModelAPI> lstuser = new List <UserModelAPI>(); lstuser = objService.getUserAPI(); objModel.ListUser = new List <UserModelAPI>(); objModel.ListUser.AddRange(lstuser); return(objModel.ListUser.Where(m => m.UID == id).ToList()); }
// PUT: api/User/5 public void Put(string token, [FromBody] UserModelAPI userModelAPI) { var user = userService.GetByToken(token); user.Email = userModelAPI.Email; user.FullName = userModelAPI.FullName; user.GroupCode = userModelAPI.GroupCode; user.Hobby = userModelAPI.Hobby; user.Password = userModelAPI.Password; userService.UpdateUser(user); }
public UserModel Map(UserModelAPI user) { return(new UserModel() { Email = user.Email, FullName = user.FullName, GroupName = user.GroupName, Hobby = user.Hobby, Password = user.Password }); }
public static UserModel USERApiToDB(UserModelAPI model) { return(new UserModel { AuthUserId = model.AuthUserId, FirstName = model.FirstName, LastName = model.LastName, EmailAddress = model.EmailAddress, CellPhone = model.CellPhone, Address = model.Address, }); }
// // GET: /APILogin/ public UserModelAPI Get(string Username, string pass) { UserModelAPI objModel = new UserModelAPI(); UserService objService = new UserService(); List <UserModelAPI> lstuser = new List <UserModelAPI>(); lstuser = objService.getUserAPI(); objModel.ListUser = new List <UserModelAPI>(); objModel.ListUser.AddRange(lstuser); return(objModel.ListUser.Where(m => m.UserName == Username && m.Password == pass && m.Status == 1).SingleOrDefault()); }
public UserModel CreateUser(UserModelAPI model) { UserForGeneric data = MapUser.USER_API_GENRIC(model); //UserModel newModel = MapUser.USERApiToDB(model); SqlDataAccess sql = new SqlDataAccess(); sql.SaveData("dbo.spUser_Insert", data, databaseNameConn); model.Address.AuthUserId = model.AuthUserId; CreateAddress(model.Address); return(MapUser.USERApiToDB(model));; }
// POST: api/Login/{mail}/{password} public string Post([FromBody] UserModelAPI objUser) { UserModel attempt = null; attempt = uServices.GetByEmail(objUser.Email); if (attempt == null) { return(null); } else if (attempt.Password == objUser.Password) { return(attempt.Type); } return(null); }
// POST: api/Login/{token} public string Post(string token, [FromBody] UserModelAPI usermodel) { UserModel attempt = null; attempt = uServices.GetByToken(token); if (attempt != null) { return("Token does not exist!"); } if (attempt.Password != null) { return("User already registered"); } attempt.FullName = usermodel.FullName; attempt.GroupName = usermodel.GroupName; attempt.Hobby = usermodel.Hobby; attempt.Password = usermodel.Password; uServices.Update(attempt); return("Registered successfully! User is " + attempt.Type); }
public UserMasterResponse UpdateAPI(UserModelAPI model) { Mapper.CreateMap <UserModelAPI, UserMaster>(); UserMaster objUser = Dbcontext.UserMasters.SingleOrDefault(m => m.UID == model.UID); if (objUser != null) { objUser = Mapper.Map(model, objUser); Dbcontext.SaveChanges(); return(new UserMasterResponse() { response = true }); } else { return(new UserMasterResponse() { response = false }); } }
public void Post(UserModelAPI newUser) { newUser.AuthUserId = RequestContext.Principal.Identity.GetUserId(); GlobalConfig.Connection.CreateUser(newUser); }
public UserModel Put([FromBody] UserModelAPI userModelAPI) { var user = userService.Login(userModelAPI.Email, userModelAPI.Password); return(user); }