public async Task <ActionResult> Create(UserView view) { try { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Logos"; if (view.LogoFile != null) { pic = FilesHelper.UploadPhoto(view.LogoFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var user = ToUser(view); user.Picture = pic; db.Users.Add(user); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.FavoriteTeamId = new SelectList(db.Teams, "TeamId", "Name", view.FavoriteTeamId); ViewBag.UserTypeId = new SelectList(db.UserTypes, "UserTypeId", "Name", view.UserTypeId); return(View(view)); } catch (Exception ex) { fileshelper.ErrorLogging(ex); return(View()); } }
public async Task <ActionResult> DeleteTeam(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var team = await db.Teams.FindAsync(id); if (team == null) { return(HttpNotFound()); } db.Teams.Remove(team); await db.SaveChangesAsync(); return(RedirectToAction(string.Format("Details/{0}", team.LeagueId))); } catch (Exception ex) { fileshelper.ErrorLogging(ex); return(View()); } }
// GET: Matches/Delete/5 public async Task <ActionResult> DeleteMatch(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var match = await db.Matches.FindAsync(id); if (match == null) { return(HttpNotFound()); } db.Matches.Remove(match); await db.SaveChangesAsync(); return(RedirectToAction(string.Format("DetailsDate/{0}", match.DateId))); } catch (Exception ex) { fileshelper.ErrorLogging(ex); return(RedirectToAction(string.Format("DetailsDate/{0}", 1))); } }