public async Task <int?> Create(AppModel model) { if (!model.IsValidForNew()) { return(null); } var app = new App { UserEmail = model.Email, Name = model.Name, Url = model.Url, IsActive = true, CreatedBy = model.CreatedBy, Description = model.Description ?? string.Empty, Tokens = new List <Token> { new Token { CreatedBy = model.CreatedBy, Key = Guid.NewGuid().ToString().Replace("-", string.Empty), UsageCount = 0, IsAppActive = true } } }; _appRepository.Create(app); if (!_appRepository.SaveChanges()) { return(null); } return(await Task.FromResult(app.Id)); }
public async Task <ActionResult> New(AppModel model) { if (!model.IsValidForNew()) { model.Msg = "bir sorun oluştu..."; return(View(model)); } model.CreatedBy = User.Identity.GetUserId(); model.Email = User.Identity.GetUserEmail(); var appId = await _appService.Create(model); if (appId == null) { model.Msg = "bir sorun oluştu..."; return(View(model)); } return(Redirect("/app/detail/" + appId)); }