public ActionResult New(Comment newComment) { newComment.DataAdaug = DateTime.Now; try { if (ModelState.IsValid) { db.Comments.Add(newComment); db.SaveChanges(); TempData["message"] = "Taskul a fost adaugat cu success!"; return(Redirect("/Tasks/Show/" + newComment.TaskId)); } TempData["message"] = "Nu s-a putut adauga comntariul!"; return(Redirect("/Tasks/Show/" + newComment.TaskId)); } catch (Exception e) { ViewBag.Message = "Nu s-a putut adauga comentariul!"; ViewBag.Message = e.Message; return(Redirect("/Tasks/Show/" + newComment.TaskId)); } }
public ActionResult New(Project project) { try { if (ModelState.IsValid) { db.Projects.Add(project); TempData["message"] = "Proiectul a fost adaugat cu succes."; db.SaveChanges(); return(Redirect("/Teams/Show/" + project.TeamId)); } else { return(View(project)); } }catch (Exception e) { ViewBag.Message = "Nu s-a putut adauga proiectul."; return(View(project)); } }
public ActionResult New(Task newTask) { try { if (ModelState.IsValid) { db.Tasks.Add(newTask); db.SaveChanges(); TempData["message"] = "Taskul a fost adaugat cu success!"; return(RedirectToAction("Index")); } return(View(newTask)); } catch (Exception e) { ViewBag.Message = "Nu s-a putut adauga task-ul!"; return(View(newTask)); } }
public ActionResult New(Team newTeam) { newTeam.DataInscriere = DateTime.Now; try { if (ModelState.IsValid) { db.Teams.Add(newTeam); db.SaveChanges(); TempData["message"] = "Echipa a fost adaugata!"; return(RedirectToAction("Index")); } else { return(View(newTeam)); } }catch (Exception e) { ViewBag.Message = "Nu s-a putut adauga echipa."; return(View(newTeam)); } }