Exemplo n.º 1
0
        public Result Execute(string userIdStr, string userPassword, DreamProperties properties)
        {
            long userId = 0;

            try
            {
                userId = long.Parse(userIdStr);
            }
            catch (Exception)
            {
                return(Result.ERROR_USER_NOT_EXISTS);
            }

            return(_accountStorage.Transaction(Result.ERROR_UNDEFINED, _ =>
            {
                if (_accountStorage.Find(userId, userPassword) == null)
                {
                    return Result.ERROR_USER_NOT_EXISTS;
                }

                _dreamsStorage.Update(new Dream
                {
                    Id = properties.Id,
                    UserId = userId,
                    Description = properties.Description,
                    IsLucid = properties.IsLucid ? 1 : 0,
                    SleepingDate = properties.SleepingDate
                });

                return Result.SUCCESS;
            }));
        }
Exemplo n.º 2
0
        public Result Execute(string userIdStr, string userPassword, DreamProperties properties)
        {
            long userId = 0;

            try
            {
                userId = long.Parse(userIdStr);
            }
            catch (Exception)
            {
                return(Result.UserNotExists);
            }

            return(_accountStorage.Transaction(Result.UserNotExists, _ =>
            {
                if (_accountStorage.Find(userId, userPassword) == null)
                {
                    return Result.UserNotExists;
                }

                var id = _dreamsStorage.Add(new Dream
                {
                    UserId = userId,
                    Description = properties.Description,
                    IsLucid = properties.IsLucid ? 1 : 0,
                    SleepingDate = properties.SleepingDate
                });

                return Result.Success(id);
            }));
        }
Exemplo n.º 3
0
        public IActionResult Fetch(
            [FromHeader(Name = AuthProperties.HEADER_AUTH_ID)] string userId,
            [FromHeader(Name = AuthProperties.HEADER_AUTH_PASSOWRD)] string userPassword,
            [FromBody] DreamProperties properties)
        {
            var result   = _editUseCase.Execute(userId, userPassword, properties);
            var response = DreamsMapper.Map(result);

            return(new JsonResult(response));
        }