public async Task<ActionResult> Register(RegisterViewModel model) { var birthdayString = string.Format("{0}/{1}/{2}", model.Day, model.Month, model.Year); DateTime birthday; var parseResult = DateTime.TryParseExact(birthdayString, DateTimeFormat.DMYYYY, CultureInfo.InvariantCulture, DateTimeStyles.None, out birthday); if (parseResult && ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var userInfo = new User { UserID = user.Id, Email = model.Email, FirstName = model.Firstname, LastName = model.Lastname, UserName = model.UserName, BirthDay = birthday, Gender = model.Gender, Relationship = (int)Relationship.Single, RegisteredDate = DateTime.UtcNow }; db.Users.Add(userInfo); db.SaveChanges(); var friendList = new FriendList { Id = user.Id, UserId = user.Id, CreatedDate = DateTime.UtcNow }; db.FriendLists.Add(friendList); var mySetting = new MySetting { SettingID = Guid.NewGuid().ToString(), UserID = user.Id, AllowOtherToPost = true, DefaultMyPostVisibility = (int)VisibleType.Friend, DefaultOtherPostVisibility = (int)VisibleType.Friend, ShowBirthday = (int)ShowBirthDay.Show }; db.MySettings.Add(mySetting); //Init default album avatar and cover db.Albums.AddRange(DefaultAlbum(user.Id)); //Init default image db.AlbumDetails.AddRange(DefaultImage(user.Id, userInfo.Gender)); db.SaveChanges(); await SignInAsync(user, isPersistent: false); return RedirectToAction("Newsfeed", "Home"); } else { AddErrors(result); } } else { ModelState.AddModelError("", Message.INVALID_BIRTHDAY); } // If we got this far, something failed, redisplay form return View(model); }
public ServiceA(MySetting setting) { this.setting = setting; }
private void Application_Startup(object sender, StartupEventArgs e) { MainDispatcher.dispatcher = Current.Dispatcher; MySetting.Load(); CreateAllWin(); }
public void RunServer() { _server = new HttpSelfHostServer(MySetting.getServerConfig()); _server.OpenAsync().Wait(); }