public async Task <ActionResult> DeleteConfirmed(Guid id) { Taska taska = await db.Tasks.FindAsync(id); db.Tasks.Remove(taska); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Taska taska = await db.Tasks.FindAsync(id); if (taska == null) { return(HttpNotFound()); } return(View(taska)); }
public async Task <ActionResult> Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Taska taska = await db.Tasks.FindAsync(id); if (taska == null) { return(HttpNotFound()); } ViewBag.CategoriesList = new SelectList(db.Categories, "CategoryName", "CategoryName"); ViewBag.CompaniesList = new SelectList(db.Companies, "CompanyName", "CompanyName"); ViewBag.StatusesList = new SelectList(db.TaskStatuses, "StatusName", "StatusName"); return(View(taska)); }
public async Task <ActionResult> Create(Taska taska) { var DateTimeNow = DateTime.Now; List <Category> category = db.Categories.ToList(); ViewBag.CategoriesList = new SelectList(category, "CategoryName", "CategoryName"); List <Company> companies = db.Companies.ToList(); ViewBag.CompaniesList = new SelectList(companies, "CompanyName", "CompanyName"); List <Models.TaskStatus> statuses = db.TaskStatuses.ToList(); ViewBag.StatusesList = new SelectList(statuses, "StatusName", "StatusName"); if (taska.LastMeetingDate > DateTimeNow) { ViewBag.LastDateError = "Дата последней встречи не может превышать нынешнюю дату"; return(View(taska)); } if (taska.TaskDate < DateTimeNow) { ViewBag.DateError = "Дата намеченной встречи не может быть меньше нынешней даты"; return(View(taska)); } if (ModelState.IsValid) { var currentUser = db.Users.Find(User.Identity.GetUserId()); string namePlusLogin = currentUser.Name + " " + currentUser.Surname + " (" + User.Identity.Name + ")"; taska.TaskId = Guid.NewGuid(); taska.ManagerName = namePlusLogin; db.Tasks.Add(taska); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(taska)); }
public async Task <ActionResult> Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Taska taska = await db.Tasks.FindAsync(id); if (taska == null) { return(HttpNotFound()); } // собираем список менеджеров // проверяем содержится ли в именах менеджеров логин нынешнего пользователя или админа // если да, то передаем во вьюшку true if (taska.ManagerName.Contains(User.Identity.Name)) { ViewBag.User = taska.ManagerName; } return(View(taska)); }