Exemplo n.º 1
0
        public async Task <IDataResult <IList <TodoOutput> > > GetListByFilter(Expression <Func <Todo, bool> > filter = null)
        {
            var todos = await _todoDal.GetList(filter);

            var todoOutputs = MapsterTool.Map <IList <Todo>, IList <TodoOutput> >(todos);

            return(new SuccessDataResult <IList <TodoOutput> >(todoOutputs, Messages.Successfully));
        }
Exemplo n.º 2
0
        public async Task <IDataResult <TodoOutput> > GetByFilter(Expression <Func <Todo, bool> > filter)
        {
            var todo = await _todoDal.Get(filter);

            var todoOutput = MapsterTool.Map <Todo, TodoOutput>(todo);

            return(new SuccessDataResult <TodoOutput>(todoOutput, Messages.Successfully));
        }
Exemplo n.º 3
0
        public async Task <IDataResult <IList <AppUserOutput> > > GetListByFilter(Expression <Func <AppUser, bool> > filter = null)
        {
            var users = await _appUserDal.GetList(filter);

            var userOutputs = MapsterTool.Map <IList <AppUser>, IList <AppUserOutput> >(users);

            return(new SuccessDataResult <IList <AppUserOutput> >(userOutputs, Messages.Successfully));
        }
Exemplo n.º 4
0
        public async Task <IDataResult <AppUserOutput> > GetByFilter(Expression <Func <AppUser, bool> > filter)
        {
            var user = await _appUserDal.Get(filter);

            var userOutput = MapsterTool.Map <AppUser, AppUserOutput>(user);

            return(new SuccessDataResult <AppUserOutput>(userOutput, Messages.Successfully));
        }
Exemplo n.º 5
0
        public async Task <IResult> Update(TodoUpdateInput updateInput)
        {
            var todo = await _todoDal.Get(t => t.Id == updateInput.Id);

            todo.TodoItems.ToList().Where(t => t.Id == null).ToList().ForEach(t => t.Id = Guid.NewGuid());
            todo.TodoItems = MapsterTool.Map <IList <TodoItemUpdateInput>, IList <TodoItem> >(updateInput.TodoItems);

            await _todoDal.Update(todo);

            return(new SuccessResult(Messages.Successfully));
        }
Exemplo n.º 6
0
        public async Task <IDataResult <TodoOutput> > Add(TodoAddInput addInput)
        {
            var todo = MapsterTool.Map <TodoAddInput, Todo>(addInput);

            todo.TodoItems.ToList().ForEach(t => t.Id = Guid.NewGuid());
            await _todoDal.Add(todo);

            var todoOutput = MapsterTool.Map <Todo, TodoOutput>(todo);

            return(new SuccessDataResult <TodoOutput>(todoOutput, Messages.Successfully));
        }
Exemplo n.º 7
0
        public async Task <IDataResult <AppUserOutput> > Add(AppUserRegisterInput registerInput)
        {
            var control = await BusinessRules.RunAsync(CheckUserEmail(registerInput.Email));

            if (!control.Success)
            {
                return(new ErrorDataResult <AppUserOutput>(control.Message));
            }

            var user = MapsterTool.Map <AppUserRegisterInput, AppUser>(registerInput);

            CreatePasswordHash(user, registerInput.Password);
            await _appUserDal.Add(user);

            var userOutput = MapsterTool.Map <AppUser, AppUserOutput>(user);

            return(new SuccessDataResult <AppUserOutput>(userOutput, Messages.Successfully));
        }