예제 #1
0
        public async Task <bool> CreateTask(TaskCreateRAO rao)
        {
            var entity = _mapper.Map <TaskDataModel>(rao);

            await _context.Task.AddAsync(entity);

            return(await _context.SaveChangesAsync() == 1);
        }
예제 #2
0
        public bool CreateTask(TaskCreateRAO rao)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = new TaskEntity
                {
                    TaskName        = rao.TaskName,
                    TaskDescription = rao.TaskDescription,
                    RewardPoints    = rao.RewardPoints,
                    GroupId         = rao.GroupId,
                    DateCreated     = DateTimeOffset.Now,
                    Completed       = false
                };

                ctx.Tasks.Add(entity);

                return(ctx.SaveChanges() == 1);
            }
        }
예제 #3
0
        public ActionResult Create(TaskCreateDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            var rao = new TaskCreateRAO
            {
                GroupId         = dto.GroupId,
                TaskName        = dto.TaskName,
                TaskDescription = dto.TaskDescription,
                RewardPoints    = dto.RewardPoints
            };

            var service = GetTaskService();

            if (service.CreateTask(rao))
            {
                return(RedirectToAction("Index", new { id = dto.GroupId }));
            }

            return(View(dto));
        }