Beispiel #1
0
        /// <summary>
        /// Save check code result for create user
        /// </summary>
        /// <param name=""></param>
        static public ReturnJasonConstruct <DTO.Account> Create(string telNo, int code)
        {
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            try
            {
                MissFreshEntities db = new MissFreshEntities();

                Models.Customer ct = new Models.Customer();
                ct.id         = Guid.NewGuid();
                ct.telNo      = telNo;
                ct.createTime = DateTime.Now;

                Models.Account ac = new Models.Account();
                ac.id     = Guid.NewGuid();
                ac.code   = code.ToString();
                ac.userId = ct.id;

                db.Customers.Add(ct);
                db.Accounts.Add(ac);
                db.SaveChanges();

                obj.status    = (int)executeStatus.success;
                obj.DTOObject = ac.ToDTO();

                return(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public StreamManagerViewModel(Account account)
        {
            _selectedIndex = -1;
            _accountModel = account;
            _streamManagerModel = account.Stream;
            _streams = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                _streamManagerModel.Streams, item => new StreamViewModel(item), App.Current.Dispatcher);

            CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this));
            _thisPropChangedEventListener.Add(() => IsActive, IsActive_PropertyChanged);
        }
Beispiel #3
0
        public AccountViewModel(Account model, MainViewModel managerVM)
        {
            _accountModel = model;
            _userName = _accountModel.Builder.Name;
            _userMailAddress = _accountModel.Builder.Email;
            _manager = managerVM;
            _stream = new StreamManagerViewModel(_accountModel);
            _notification = new NotificationManagerViewModel(_accountModel.Notification);
            OpenAccountListCommand = new ViewModelCommand(OpenAccountListCommand_Execute);
            ActivateCommand = new ViewModelCommand(ActivateCommand_Execute);
            CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this));

            _thisPropChangedEventListener.Add(() => IsActive, IsActive_PropertyChanged);
            DataCacheDictionary
                .DownloadImage(new Uri(_accountModel.Builder.IconUrl.Replace("$SIZE_SEGMENT", "s38-c-k")))
                .ContinueWith(tsk => UserIconUrl = tsk.Result);
        }
Beispiel #4
0
        public AccountController(ApiContext context)
        {
            _context = context;

            if (_context.Account.Count() == 0)
            {
                var one = new Models.Account {
                    AccountNumber = "Qwe", Balance = 12
                };
                var two = new Models.Account {
                    AccountNumber = "Asd", Balance = 15
                };

                _context.Account.Add(one);
                _context.Account.Add(two);

                _context.SaveChanges();
            }
        }
Beispiel #5
0
        public static ReturnJasonConstruct <DTO.Account> Update(DTO.Account account)
        {
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            try
            {
                Models.Account    acc = account.ToModel();
                MissFreshEntities db  = new MissFreshEntities();
                var model             = db.Accounts.SingleOrDefault(p => p.Customer.telNo == acc.Customer.telNo && p.Customer.password == null);
                if (model == null)
                {
                    obj.SetWarningInformation("用于已存在!请检查手机号输入是否正确.");
                    return(obj);
                }
                else
                {
                    if (model.code == acc.code)
                    {
                        model.code = SMS.GetRandomCode().ToString();
                        model.Customer.firstName = acc.Customer.firstName;
                        model.Customer.lastName  = acc.Customer.lastName;
                        model.Customer.email     = acc.Customer.email;
                        model.Customer.password  = acc.Customer.password;
                        db.SaveChanges();
                        obj.SetDTOObject(model.ToDTO());
                    }
                    else
                    {
                        obj.SetWarningInformation("验证码输入错误,请重新输入.");
                    }
                    return(obj);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Http : POST
        /// </summary>
        public async Task PostAccount()
        {
            await Task.Run(async () =>
            {
                using (RESTWebClient client = new RESTWebClient())
                {
                    string postUrl = "http://localhost:8001/accounts";
                    Account newAccount = new Account();
                    newAccount.SortCode = string.Format("SortCode_{0}", DateTime.Now.Ticks);
                    newAccount.AccountNumber = string.Format("AccountNumber_{0}", DateTime.Now.Ticks);

                    //the server AccountHandler [RouteBaseAttribute] is set to return Json, 
                    //so we need to deserialize it as Json 
                    var response = await client.Post<Account>(postUrl, newAccount, SerializationToUse.Json);
                    Console.WriteLine("Http : POST");
                    Console.WriteLine("Status Code : {0}", response.StatusCode);
                    Console.WriteLine(postUrl);
                    Console.WriteLine(response.Content);
                    Console.WriteLine("=================================");

                }
            });
        }
 public void Set(Account value)
 {
     HttpContext.Current.Session["ContextAccount"] = value;
 }