Esempio n. 1
0
        public override async Task <Empty> AddToDo(AddToDoRequest request, ServerCallContext context)
        {
            var command = new CreateToDoCommand(request.Id, request.Description, request.Username);
            await _mediator.Send(command);

            return(new Empty());
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] AddToDoRequest request)
        {
            var addToDoCommand = new AddToDoCommand(request.Title, request.Completed, request.Order);

            await _commandProcessor.SendAsync(addToDoCommand);

            var addedToDo = await _queryProcessor.ExecuteAsync(new ToDoByIdQuery(addToDoCommand.ToDoItemId));

            addedToDo.Url = Url.RouteUrl("GetTodo", new { id = addedToDo.Id }, protocol: Request.Scheme);

            return(CreatedAtRoute("GetTodo", new { id = addedToDo.Id }, addedToDo));
        }
Esempio n. 3
0
        public JsonResult ToDo_Insert(AddToDoRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            //IList<Guid> id=new List<Guid>();
            //id.Add(Guid.Parse("12D942E9-9B2F-42A9-82D5-66D661FAC17D"));
            //AddToDoRequest test = new AddToDoRequest() {
            //    EmployeeIDs=id,
            //    EndDate="1392/10/10",
            //    EndTime="10:20",
            //    PrimaryClosed=false,
            //    PriorityType=(int)PriorityType.High,
            //    StartDate="1392/10/02",
            //    StartTime="20:10",
            //    ToDoDescription="این کار خیلی مهمه بچه ها",
            //    ToDoTitle="یک کار مهم"
            //};

            response = _toDoService.AddTodo(request, GetEmployee().ID);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public GeneralResponse AddTodo(AddToDoRequest request, Guid CreateEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                ToDo toDo = new ToDo();
                toDo.ID             = Guid.NewGuid();
                toDo.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID);
                toDo.CreateDate     = PersianDateTime.Now;
                toDo.Customer       = _customerRepository.FindBy(request.CustomerID);
                if (request.EndDate != null)
                {
                    toDo.EndDate = request.EndDate;
                }
                else
                {
                    toDo.EndDate = request.StartDate;
                }
                toDo.EndTime         = request.EndTime;
                toDo.StartDate       = request.StartDate;
                toDo.StartTime       = request.StartTime;
                toDo.PrimaryClosed   = false;
                toDo.PriorityType    = PriorityType.High;
                toDo.ToDoTitle       = request.ToDoTitle;
                toDo.ToDoDescription = request.ToDoDescription;
                toDo.RowVersion      = 1;
                // اگر لیست کارمندان آمد یعنی وظیفه مربوط به کارمندان است
                if (request.EmployeeIDs != null)
                {
                    IList <ToDoResult> toDoResults = new List <ToDoResult>();
                    foreach (Guid iD in request.EmployeeIDs)
                    {
                        Employee employee = _employeeRepository.FindBy(iD);

                        ToDoResult toDoResult = new ToDoResult();
                        toDoResult.ID                    = Guid.NewGuid();
                        toDoResult.CreateEmployee        = _employeeRepository.FindBy(CreateEmployeeID);
                        toDoResult.CreateDate            = PersianDateTime.Now;
                        toDoResult.ToDo                  = toDo;
                        toDoResult.Remindable            = request.Remindable;
                        toDoResult.RemindeTime           = request.RemindeTime;
                        toDoResult.ReferedEmployee       = employee;
                        toDoResult.RowVersion            = 1;
                        toDoResult.ToDoResultDescription = "";
                        toDoResults.Add(toDoResult);
                    }
                    toDo.ToDoResults = toDoResults;
                    toDo.IsGrouped   = false;
                }
                //اگر لیست گروه ها آمد به معنی اینکه این وظیفه گروهی است
                if (request.GroupIDs != null)
                {
                    IList <ToDoResult> toDoResults = new List <ToDoResult>();
                    foreach (Guid iD in request.GroupIDs)
                    {
                        IEnumerable <Employee> employees = _employeeRepository.FindAll().Where(x => x.Group.ID == iD);
                        foreach (Employee employee in employees)
                        {
                            ToDoResult toDoResult = new ToDoResult();
                            toDoResult.ID                    = Guid.NewGuid();
                            toDoResult.CreateEmployee        = _employeeRepository.FindBy(CreateEmployeeID);
                            toDoResult.CreateDate            = PersianDateTime.Now;
                            toDoResult.ToDo                  = toDo;
                            toDoResult.Remindable            = request.Remindable;
                            toDoResult.RemindeTime           = request.RemindeTime;
                            toDoResult.ReferedEmployee       = employee;
                            toDoResult.RowVersion            = 1;
                            toDoResult.ToDoResultDescription = "";
                            toDoResults.Add(toDoResult);
                        }
                    }
                    toDo.ToDoResults = toDoResults;
                    toDo.IsGrouped   = false;
                }
                if (request.GroupIDs == null && request.EmployeeIDs == null)
                {
                    IList <ToDoResult> toDoResults = new List <ToDoResult>();

                    ToDoResult toDoResult = new ToDoResult();
                    toDoResult.ID                    = Guid.NewGuid();
                    toDoResult.CreateEmployee        = _employeeRepository.FindBy(CreateEmployeeID);
                    toDoResult.CreateDate            = PersianDateTime.Now;
                    toDoResult.ToDo                  = toDo;
                    toDoResult.Remindable            = request.Remindable;
                    toDoResult.RemindeTime           = request.RemindeTime;
                    toDoResult.ReferedEmployee       = _employeeRepository.FindBy(CreateEmployeeID);
                    toDoResult.RowVersion            = 1;
                    toDoResult.ToDoResultDescription = "";
                    toDoResults.Add(toDoResult);
                    toDo.ToDoResults = toDoResults;
                    toDo.IsGrouped   = false;
                }
                _toDoRepository.Add(toDo);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }
            return(response);
        }