Esempio n. 1
0
        public HttpResponseMessage Put(account newAccount)
        {
            //AccountSvc svc = new AccountSvc();

            var result = _svc.CreateAccount(newAccount);

            return Request.CreateResponse(HttpStatusCode.OK, result);
        }
Esempio n. 2
0
        public AccountResult CreateAccount(account newAccount)
        {
            try
            {
                if (newAccount == null)
                    return new AccountResult(AccountStatus.ErrorInRequest);

                account account = new account
                {
                    id = Guid.NewGuid().ToString(),
                    provider = newAccount.provider,
                    token = newAccount.token,
                    userName = newAccount.userName,
                    jsonUserInfo = newAccount.jsonUserInfo
                };

                _db.account.Add(account);
                _db.SaveChanges();

                return new AccountResult(account);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
 public AccountResult(account account)
 {
     Account = account;
     Status = AccountStatus.Success;
     StatusMessage = Status.ToString();
 }
Esempio n. 4
0
        public AccountResult UpdateAccount(account account)
        {
            try
            {
                if (account == null)
                    return new AccountResult(AccountStatus.ErrorInRequest);

                var accountDb = _db.account.FirstOrDefault(a => a.id == account.id);

                if (accountDb != null)
                {
                    accountDb.partyId = account.partyId;

                    _db.Entry(accountDb).State = EntityState.Modified;
                    _db.SaveChanges();

                    return new AccountResult(accountDb);
                }
                else
                    return new AccountResult(AccountStatus.Error);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }