public async Task <HttpResponseMessage> Post(BO.Member.Member model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } model.UpdatedAt = DateTime.Now; // ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(model.UserId); model.IdentityUser = null; //var store = new UserStore<ApplicationUser>(); //var manager = new UserManager<ApplicationUser>(store); //var user = new ApplicationUser(); //user.Email = model.Email; //user.EmailConfirmed = true; //user.UserName = model.Email; //manager.Create(user, model.Password); //manager.AddToRole(user.Id, "Member"); applicationResult.Result = await _service.CreateAsync(model); return(Request.CreateResponse <ApplicationResult>(HttpStatusCode.OK, applicationResult)); }
public async Task <HttpResponseMessage> GetUserInfo() { ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity); var Members = this._service.Get(); BO.Member.Member LMSMember = new BO.Member.Member(); if (Members != null && Members.Count > 0) { LMSMember = Members.Where(m => m.UserId == User.Identity.GetUserId()).FirstOrDefault(); if (LMSMember != null) { LMSMember.UserId = null; } } ApplicationResult applicationResult = new ApplicationResult(); applicationResult.Result = new UserInfoViewModel { Email = User.Identity.GetUserName(), HasRegistered = externalLogin == null, LoginProvider = externalLogin != null ? externalLogin.LoginProvider : null, Member = LMSMember }; return(Request.CreateResponse <ApplicationResult>(HttpStatusCode.OK, applicationResult)); }
public async Task <HttpResponseMessage> Put(int id, BO.Member.Member model) { if (!ModelState.IsValid || id != model.Id) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } model.UpdatedAt = DateTime.Now; applicationResult.Result = await _service.UpdateAsync(model); return(Request.CreateResponse <ApplicationResult>(HttpStatusCode.OK, applicationResult)); }