public async Task <GetCardTaskDetailCommandResult> Handle(GetCardTaskDetailCommand request, CancellationToken cancellationToken) { GetCardTaskDetailCommandResult result = new GetCardTaskDetailCommandResult { ResultObject = new ServiceResult <GetCardTaskDetailCommandResultItem> { Success = false, ServiceMessageList = new List <ServiceMessage>(), Data = new GetCardTaskDetailCommandResultItem() } }; try { var validator = new GetCardTaskDetailCommandValidator(); var validationResult = validator.Validate(request); if (validationResult.IsValid) { CardTask cardTask = _cardTaskRepository.Get(x => x.CardTaskId == request.CardTaskId); result.ResultObject.Success = true; result.ResultObject.Data = new GetCardTaskDetailCommandResultItem { CardId = cardTask.CardId, Text = cardTask.Text, CardTaskId = cardTask.CardTaskId }; } else { foreach (var item in validationResult.Errors) { result.ResultObject.ServiceMessageList.Add(new ServiceMessage() { ServiceMessageType = eServiceMessageType.Error, UserFriendlyText = item.ErrorMessage }); } result.ResultObject.Success = false; } } catch (Exception ex) { result.ResultObject.ServiceMessageList.Add(new ServiceMessage() { ServiceMessageType = eServiceMessageType.Error, UserFriendlyText = "An error occured", LogText = "BoardService.GetBoardSwimLanes() method error message: " + ex.Message, SystemException = ex }); } return(result); }
public async Task <IActionResult> CreateTaskAsync(CardTask task, string department) { if (ModelState.IsValid) { ViewBag.Departments = new SelectList(dbContext.Departments.Select(d => d.Name)); if (task.DateEnd <= task.DateBegin) { ModelState.AddModelError("", "Время окончания обхода не может быть меньше или равным времени начала обхода"); return(View(task)); } CardTask newCard = new CardTask() { DateBegin = task.DateBegin, DateEnd = task.DateEnd, DepartmentId = await dbContext.Departments.Where(d => d.Name.Equals(department)).Select(d => d.Id).FirstOrDefaultAsync(), Desc = task.Desc, Name = task.Name, State = false, UserId = dbContext.Users.Where(u => u.UserName.Equals(User.Identity.Name)).Select(u => u.Id).FirstOrDefault() }; await dbContext.CardTasks.AddAsync(newCard); dbContext.SaveChanges(); var url = RedirectToAction("Tasks"); url.RouteValues = new RouteValueDictionary(); var result = url.RouteValues.TryAdd("department", RouteData.Values["department"]); if (!result) { ModelState.AddModelError("", "Ошибка переадресовки"); ViewBag.Department = RouteData.Values["department"]; return(View()); } return(url); } else { ModelState.AddModelError("", "Ошибка ввода данных"); ViewBag.Department = RouteData.Values["department"]; } return(View()); }
public CommandResult <bool> Execute(RedfernDb db) { CardTask task = db.CardTasks.Find(this.CardTaskId); Activity activity = db.Activities.Create(); activity.ActivityDate = DateTime.UtcNow; activity.SetVerb("deleted"); activity.SetActor(db.Context.ClientUserName, db.Context.ClientUserFullName); activity.SetObject("task", task.CardTaskId.ToString(), task.Description.Substring(0, task.Description.Length < 30 ? task.Description.Length - 1 : 25), ""); activity.SetTarget("card", task.CardId.ToString(), task.Card.Title, String.Format(@"#/board/{0}/card/{1}", task.Card.BoardId.ToString(), task.CardId.ToString())); activity.SetContext("board", task.Card.BoardId.ToString(), task.Card.Board.Name, String.Format(@"/board/{0}", task.Card.BoardId)); activity.SetDescription("<b>{actorlink}</b> deleted <b>{object}</b> from <b>{contextlink}</b>"); activity = db.Activities.Add(activity); db.CardTasks.Remove(task); db.SaveChanges(); return(this.CommandResult <bool>(true, db, activity)); }
public async Task <IActionResult> EditTaskAsync(CardTask task) { if (ModelState.IsValid) { if (task.DateEnd <= task.DateBegin) { ModelState.AddModelError("", "Время окончания обхода не может быть меньше или равным времени начала обхода"); return(View(task)); } var uTask = await dbContext.CardTasks.FirstOrDefaultAsync(c => c.Id.Equals(task.Id)); uTask.Desc = task.Desc; uTask.Name = task.Name; if (uTask.DateBegin > DateTime.Now) { uTask.DateBegin = task.DateBegin; uTask.DateEnd = task.DateEnd; } dbContext.CardTasks.Update(uTask); await dbContext.SaveChangesAsync(); var url = RedirectToAction("Tasks"); url.RouteValues = new RouteValueDictionary(); var result = url.RouteValues.TryAdd("department", RouteData.Values["department"]); if (!result) { ModelState.AddModelError("", "Ошибка переадресовки"); ViewBag.Department = RouteData.Values["department"]; return(View(task)); } return(url); } else { ModelState.AddModelError("", "Введены некорректные данные"); ViewBag.Department = RouteData.Values["department"]; } return(View(task)); }
private void Awake() { task = GetComponentInParent <CardTask>(); }