Exemplo n.º 1
0
        public Result Execute(string userIdStr, string userPassword, long dreamId)
        {
            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.Delete(dreamId);

                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.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.º 3
0
        public Result Execute(string userIdString, string userPassword)
        {
            long userId = 0;

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

            return(_accountStorage.Transaction(Result.ERROR_UNDEFINED, _ =>
            {
                var user = _accountStorage.Find(userId, userPassword);

                if (user == null)
                {
                    return Result.ERROR_USER_NOT_EXISTS;
                }

                _accountStorage.Delete(userId);
                _dreamsStorage.DeleteAllForUser(userId);

                return Result.SUCCESS;
            }));
        }