コード例 #1
0
ファイル: AccountManager.cs プロジェクト: reciosonny/medcreda
        public RegisterStatus RegisterAsPatient(RegisterPatientViewModel vm)
        {
            try {
                using (var db = new MedCredaEntities()) {
                    Account account         = new Account();
                    var     isAccountExists = db.Accounts.Where(x => x.Username == vm.Username || x.EmailAddress == vm.EmailAddress).Any();
                    if (isAccountExists)
                    {
                        return(RegisterStatus.EmailUsernameExists);
                    }

                    var viewModelParser = new ViewModelParser <Account, RegisterPatientViewModel>(account, vm);
                    viewModelParser.UpdateModelState();
                    db.Accounts.Add(account);
                    db.SaveChanges();
                }
            }
            catch (Exception ex) {
                //result = false;
                //throw;
            }

            return(RegisterStatus.Registered);
            //return result;
        }
コード例 #2
0
ファイル: AccountManager.cs プロジェクト: reciosonny/medcreda
        public void CreateAccount(AccountViewModel vm)
        {
            using (var db = new MedCredaEntities()) {
                Account account = new Account();

                var viewModelParser = new ViewModelParser <Account, AccountViewModel>(account, vm);
                viewModelParser.UpdateModelState();
                db.Accounts.Add(account);
                db.SaveChanges();
            }
            //throw new NotImplementedException();
        }