public async Task <ActionResult <Account> > PostAccount(AccountObject accountObject)
        {
            //if (!RequestHelper.ValidateId(accountObject.OwnerId, Request, _env))
            //    return BadRequest("HeaderId and Id are not equal");
            try
            {
                var account = new Account
                {
                    Balance   = accountObject.Balance,
                    OwnerId   = accountObject.OwnerId,
                    OwnerName = accountObject.OwnerName
                };
                _context.Accounts.Add(account);
                await _context.SaveChangesAsync();

                _rabbitMqClient.SendMessage(new HistoryMessage {
                    Event = "CreatedBankAccount", EventMessage = $"Created bank account", User = accountObject.OwnerId, Timestamp = DateTime.UtcNow
                });
                _logger.LogInformation("Successfully created {@Account}", account);
                return(CreatedAtAction("GetAccount", new { id = account.OwnerId }, account));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to create account");
                throw;
            }
        }
示例#2
0
 public ActionResult Login(AccountObject obj)
 {
     if (ModelState.IsValid)
     {
         var result = new AccountBCL().Login(obj.UserName, obj.Password);
         if (result == 1)
         {
             AccountObject objAccount = new AccountBCL().CheckLogin(obj.UserName, obj.Password);
             Session.Add(Comomconstants.USER_SESSION, objAccount);
             return(RedirectToAction("Index", "Home"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Tài khoản không tồn tại");
         }
         else if (result == -1)
         {
             ModelState.AddModelError("", "Tài khoản đang bị khóa");
         }
         else if (result == -2)
         {
             ModelState.AddModelError("", "Mật khẩu không tồn tại");
         }
         else if (result == 2)
         {
             ModelState.AddModelError("", "Tài khoản bạn đã bị xóa");
         }
     }
     return(View("Index"));
 }
 public ActionResult Edit(AccountObject ob)
 {
     try
     {
         if (new AccountBCL().GetAll().Count(q => q.Username == ob.Username) == 2)
         {
             ModelState.AddModelError("", "Tên đăng nhập đã được sử dụng cho người dùng khác");
         }
         else
         {
             ob.Isdeleted = false;
             new AccountBCL().Update(ob);
             var objExper = new ExpertsBCL().GetByExpertId(ob.UserId);
             if (objExper != null)
             {
                 objExper.FullName    = ob.FullName;
                 objExper.Email       = ob.Username;
                 objExper.Email       = ob.Email;
                 objExper.Mobile      = ob.Phone;
                 objExper.Description = ob.Description;
                 new ExpertsBCL().Update(objExper);
             }
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         ModelState.AddModelError("", "Sửa không thành công");
     }
     return(View());
 }
        public List <AccountObject> GetAll()
        {
            var list = new CarOnlineEntities().WEB_CARONLINE_SP_Account_GetAll().ToList();
            List <AccountObject> lst = new List <AccountObject>();

            foreach (var item in list)
            {
                AccountObject obj = new AccountObject();

                obj.AccountID           = item.AccountID;
                obj.ID_Facebook         = item.ID_Facebook;
                obj.ID_Gmail            = item.ID_Gmail;
                obj.UserName            = item.UserName;
                obj.Password            = item.Password;
                obj.Avatar              = item.Avatar;
                obj.FullName            = item.FullName;
                obj.RoleID              = item.RoleID.GetValueOrDefault();
                obj.NumberOfLikeProfile = item.NumberOfLikeProfile.GetValueOrDefault();
                obj.NumberOfPost        = item.NumberOfPost.GetValueOrDefault();
                obj.NumberOfFlow        = item.NumberOfFlow.GetValueOrDefault();
                obj.NumberOfComment     = item.NumberOfComment.GetValueOrDefault();
                obj.Mobile              = item.Mobile;
                obj.Active              = (bool)item.Active;
                obj.BirthDay            = item.BirthDay.GetValueOrDefault();
                obj.JoinDay             = item.JoinDay.GetValueOrDefault();
                obj.Email     = item.Email;
                obj.Address   = item.Address;
                obj.IsDeleted = item.IsDeleted.GetValueOrDefault(false);
                obj.RoleObj   = new RoleDao().GetById(obj.RoleID);
                lst.Add(obj);
            }
            return(lst);
        }
示例#5
0
        // GET api/values
        public object Get()
        {
            var add = new Address();

            add.name     = "Hoàng hôn";
            add.location = "Hà Nội";

            var account = new AccountObject();

            account.name = "Dương Đắc Khanh";
            account.data = add;

            var voucher = new Voucher();

            voucher.account = account;
            var voucher2 = new Voucher();

            voucher2.account = account;
            var voucher3 = new Voucher();

            voucher3.account = account;

            var list = new List <object> {
                voucher, voucher2, voucher3
            };
            var oServiceResult = new ServiceResult(data: list);

            return(oServiceResult);
        }
        public AccountObject CheckUsername(string username)
        {
            var list = new CarOnlineEntities().WEB_CARONLINE_SP_Account_CheckUserName(username);

            foreach (var item in list)
            {
                AccountObject obj = new AccountObject();

                obj.AccountID           = item.AccountID;
                obj.ID_Facebook         = item.ID_Facebook;
                obj.ID_Gmail            = item.ID_Gmail;
                obj.RoleID              = (byte)item.RoleID;
                obj.UserName            = item.UserName;
                obj.Password            = item.Password;
                obj.Avatar              = item.Avatar;
                obj.FullName            = item.FullName;
                obj.NumberOfLikeProfile = item.NumberOfLikeProfile.GetValueOrDefault();
                obj.NumberOfPost        = item.NumberOfPost.GetValueOrDefault();
                obj.NumberOfFlow        = item.NumberOfFlow.GetValueOrDefault();
                obj.NumberOfComment     = item.NumberOfComment.GetValueOrDefault();
                obj.Mobile              = item.Mobile;
                obj.Active              = (bool)item.Active;
                obj.BirthDay            = item.BirthDay.GetValueOrDefault();
                obj.JoinDay             = item.JoinDay.GetValueOrDefault();
                obj.Email     = item.Email;
                obj.Address   = item.Address;
                obj.IsDeleted = item.IsDeleted.GetValueOrDefault();
                return(obj);
            }
            return(null);
        }
示例#7
0
        public ActionResult ConfirmEmail(AccountObject objAccount)
        {
            //objAccount.Gender = Request["Gender"].Equals("male"); // Lấy giới tính string => bool

            // Check email empty string + không trùng trong db
            if (string.IsNullOrEmpty(objAccount.Email) && AccountBCL.CheckEmail(objAccount.Email))
            {
                // Nếu email trống hoặc đã tồn tại, tải lại trang và yêu cầu kiểm tra lại
                ViewBag.ErrorEmail = true; // Mình thích thì mình báo lỗi thôi
                return(View(objAccount));
            }

            // Email đã hợp lệ
            // Cho phép thêm tài khoản vào csdl
            objAccount.AccountID = Guid.NewGuid();
            //objAccount.RoleId = 3; // tk thường
            //objAccount.ModifiedTime = DateTime.Now;
            new AccountBCL().Insert(objAccount);

            // Tạo session
            Session.Add(Comomconstants.USER_SESSION, objAccount);

            // Tải lại trang
            return(RedirectToAction("Index", "Home"));
        }
示例#8
0
        /// <summary>
        ///     Add new account to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            AccountObject account = new AccountObject();

            account = businessLogicLayer.CheckAccountsByName(accountNameInput.Text.ToLower());
            try
            {
                if (accountNameInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input the text box.");
                    accountNameInput.Focus();
                    return;
                }
                else if (accountNameInput.Text.ToLower().Equals(account.name))
                {
                    MessageBox.Show("An account with this name already exists.");
                    accountNameInput.Focus();
                    return;
                }
                else
                {
                    account = businessLogicLayer.InsertNewAccount(accountNameInput.Text.ToLower());
                    MessageBox.Show(accountNameInput.Text + " has been added to the system.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }
 public ActionResult Create(AccountObject obj)
 {
     try
     {
         if (new AccountBCL().GetAll().Any(q => q.Username.Trim().ToLower() == obj.Username.Trim().ToLower()))
         {
             ModelState.AddModelError("", "Tên đăng nhập đã được sử dụng cho người dùng khác");
         }
         else
         {
             obj.UserId    = Guid.NewGuid();
             obj.Isdeleted = false;
             if (new AccountBCL().Insert(obj))
             {
                 return(RedirectToAction("Index", "Account"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm thất bại");
             }
         }
     }
     catch
     {
         ModelState.AddModelError("", "Có lỗi xảy ra, Liên hệ với Developer");
     }
     return(View());
 }
示例#10
0
 public ActionResult Create(AccountObject obj, HttpPostedFileBase Avatar)
 {
     if (ModelState.IsValid)
     {
         if (Avatar != null)
         {
             string name = System.IO.Path.GetFileName(Avatar.FileName);
             string path = System.IO.Path.Combine(Server.MapPath("~/Areas/Admin/Content/assets/ImageAccount/images"), name);
             Avatar.SaveAs(path);
             obj.Avatar = Avatar.FileName;
         }
         obj.AccountID = Guid.NewGuid();
         obj.JoinDay   = DateTime.Now;
         obj.IsDeleted = false;
         var ob = new AccountBCL().Insert(obj);
         if (ob == true)
         {
             return(RedirectToAction("Index", "Account"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm thất bại");
         }
     }
     return(View("index"));
 }
        public async Task <Tuple <AccountObject, AtNotify> > CreateAccountObject(AccountObject input, List <string> ListIdDepartment, List <string> ListIdRole, string userId)
        {
            try
            {
                var checkAccount = await _context.AccountObject.AnyAsync(c => c.UserName == input.UserName);

                if (!checkAccount)
                {
                    input.PassWord      = EncryptProvider.Sha1(input.PassWord);
                    input.AtCreatedDate = GetDateTimeFromServer();

                    var model = await _context.AccountObject.AddAsync(input);

                    foreach (var itemD in ListIdDepartment)
                    {
                        var model_DA = new Department_Account
                        {
                            AtCreatedBy        = userId,
                            AtCreatedDate      = GetDateTimeFromServer(),
                            AtLastModifiedBy   = userId,
                            AtLastModifiedDate = GetDateTimeFromServer(),
                            AtRowStatus        = (int)AtRowStatus.Normal,
                            FK_AccountObject   = input.Id,
                            FK_Department      = itemD
                        };
                        await _context.Department_Account.AddAsync(model_DA);
                    }

                    foreach (var itemR in ListIdRole)
                    {
                        var model_RA = new Role_AccountObject
                        {
                            AtCreatedBy        = userId,
                            AtCreatedDate      = GetDateTimeFromServer(),
                            AtLastModifiedBy   = userId,
                            AtLastModifiedDate = GetDateTimeFromServer(),
                            AtRowStatus        = (int)AtRowStatus.Normal,
                            FK_AccountObject   = input.Id,
                            FK_Role            = itemR,
                        };
                        await _context.Role_AccountObject.AddAsync(model_RA);
                    }

                    await _context.SaveChangesAsync();

                    await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Thêm mới AccountObject với ID: " + model.Entity.Id, UserID = userId }, AtSerialNoConts.CODE_LOG_CREATE);

                    return(new Tuple <AccountObject, AtNotify>(model.Entity, AtNotify.InsertCompelete));
                }
                else
                {
                    return(new Tuple <AccountObject, AtNotify>(null, AtNotify.DuplicateCode));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#12
0
 public bool Insert(AccountObject ob)
 {
     if (GetAll().Find(q => q.Username.Trim().ToLower().Equals(ob.Username)) != null)
     {
         return(false);
     }
     return(new AccountDao().Insert(ob));
 }
示例#13
0
        public ActionResult Create()
        {
            AccountObject objAccount = (AccountObject)Session[Comomconstants.USER_SESSION];
            var           RoleOfUser = GetOderNumber(objAccount.AccountID);

            ViewBag.ListRole = new RoleBCL().GetAll().Where(x => GetOderNumberRole(x.RoleID) > RoleOfUser);
            return(View());
        }
示例#14
0
        public async Task <ActionResult> LoginGoogle(CancellationToken cancellationToken)
        {
            var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).
                         AuthorizeAsync(cancellationToken);

            if (result.Credential == null)
            {
                return(new RedirectResult(result.RedirectUri));
            }

            var plusService = new PlusService(new BaseClientService.Initializer
            {
                HttpClientInitializer = result.Credential,
                ApplicationName       = "MvcLogin App"
            });

            // Lấy thông tin cơ bản của user
            var me = plusService.People.Get("me").Execute();

            if (me != null)
            {
                // Kiểm tra xem tk đã có trong csdl chưa qua google id
                var objAccountRsChecked = AccountBCL.CheckGoogleId(me.Id);
                if (objAccountRsChecked != null)
                {
                    // Đã có trong csdl rồi
                    // Tạo session đăng nhập thành công
                    Session.Add(Comomconstants.USER_SESSION, objAccountRsChecked);

                    // Tải lại trang
                    return(RedirectToAction("Index", "Home"));
                }
                // Nếu chưa có tk, insert vào csdl đăng ký. Sau đó tạo session đăng nhập thành công
                // Đóng gói đối tượng
                var objAccount = new AccountObject()
                {
                    Email    = me.Emails.ElementAt(0).Value,
                    FullName = me.Name.GivenName + " " + me.Name.FamilyName,
                    ID_Gmail = me.Id,
                    Avatar   = me.Image.Url
                };
                //string DisplayName = me.DisplayName;
                //string Provider = IdentityProvider.Google;

                // Insert tk xuống csdl
                objAccount.AccountID = Guid.NewGuid();
                //objAccount.RoleId = 3; // tk thường
                //objAccount.ModifiedTime = DateTime.Now;
                new AccountBCL().Insert(objAccount);

                // Tạo session
                Session.Add(Comomconstants.USER_SESSION, objAccount);

                // Tải lại trang
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
示例#15
0
 public MatchContainer(int number, MatchObject match, AccountObject me, AccountObject opponent, Action <MatchContainer> matchCompleteCallback = null)
 {
     this.number                = number;
     this.match                 = match;
     this.me                    = me;
     this.opponent              = opponent;
     MatchComplete              = matchCompleteCallback;
     Repository.OnObjectUpdate += Repository_OnObjectUpdate;
 }
示例#16
0
        public bool Insert(AccountObject ob)
        {
            if (GetAll().Find(q => q.Username.Trim().ToLower() == ob.Username) != null)
            {
                return(false);
            }
            var db = new eTrainingScheduleEntities();

            return(db.sp_tbl_Account_INSERT(ob.UserId, ob.FullName, ob.PassWord, ob.Username, ob.Email, ob.Phone, ob.Description, ob.Isdeleted, ob.RoleId) > 0);
        }
示例#17
0
 public Permission(AccountObject acc)
 {
     // TODO: Complete member initialization
     this.Account = acc;
     if (Account != null)
     {
         Account.RoleJoin = new RoleBCL().GetByRoleId((Guid)Account.RoleId);
         ListPermission   = new PermisstionBCL().GetJoin().Where(q => q.UserId == Account.UserId).ToList();
     }
 }
示例#18
0
 void AuthorizationManager_OnAuthorizationChanged(AuthorizationManager.AuthorizationData authorization)
 {
     Repository.OnObjectUpdate -= Repository_OnObjectUpdate;
     if (authorization.IsNull())
     {
         me = null;
         return;
     }
     me = authorization.UserNameData.FullAccount.Account;
     Repository.OnObjectUpdate += Repository_OnObjectUpdate;
 }
示例#19
0
 public eRole GetRole(AccountObject acc)
 {
     if (acc == null)
     {
         return(eRole.ChuyenGia);
     }
     if (acc.RoleJoin == null)
     {
         acc.RoleJoin = new RoleBCL().GetByRoleId((Guid)acc.RoleId);
     }
     return(iRole(acc.RoleJoin.RName));
 }
示例#20
0
        public AccountObject GetByUserId(Guid ID)
        {
            var db   = new eTrainingScheduleEntities();
            var list = db.sp_tbl_Account_GetByUserId(ID);

            foreach (var item in list)
            {
                AccountObject obj = new AccountObject();
                obj.UserId = item.UserId; obj.FullName = item.FullName; obj.PassWord = item.PassWord; obj.Username = item.Username; obj.Email = item.Email; obj.Phone = item.Phone; obj.Description = item.Description; obj.Isdeleted = item.Isdeleted; obj.RoleId = item.RoleId;
                return(obj);
            }
            return(null);
        }
示例#21
0
        public AccountObject CheckLogin(AccountObject obj)
        {
            var db   = new eTrainingScheduleEntities();
            var list = db.sp_Account_CheckLogin(obj.Username, obj.PassWord);

            foreach (var item in list)
            {
                AccountObject ob = new AccountObject();
                ob.UserId = item.UserId; ob.FullName = item.FullName; ob.PassWord = item.PassWord; ob.Username = item.Username; ob.Email = item.Email; ob.Phone = item.Phone; ob.Description = item.Description; ob.Isdeleted = item.Isdeleted; ob.RoleId = item.RoleId;
                return(ob);
            }
            return(null);
        }
示例#22
0
    public void CheckState()
    {
        switch (game.State)
        {
        case ChainTypes.GameState.Complete:
            // game complete
            var revealMoves = (game.GameDetails as RockPaperScissorsGameDetailsData).RevealMoves;
            for (var i = 0; i < game.Players.Length; i++)
            {
                gestures[game.Players[i]] = revealMoves.IsNullOrEmpty() ? null : revealMoves[i].IsNull() ? null : new Gesture?(revealMoves[i].Gesture);
            }
            if (game.Winners.OrEmpty().Length == 1)
            {
                if (game.Winners.First().Equals(me.Id))
                {
                    winner = me;
                }
                else
                if (game.Winners.First().Equals(opponent.Id))
                {
                    winner = opponent;
                }
            }
            if (!GameComplete.IsNull())
            {
                GameComplete.Invoke(this);
            }
            Dispose();
            break;

        case ChainTypes.GameState.ExpectingCommitMoves:
            // wait commit
            if (!currentCommitAndReveal.IsNull())
            {
                currentCommitAndReveal.Commit(game);
            }
            else if (!GameExpectedMove.IsNull())
            {
                GameExpectedMove.Invoke(this);
            }
            break;

        case ChainTypes.GameState.ExpectingRevealMoves:
            // wait reveal
            if (!currentCommitAndReveal.IsNull())
            {
                currentCommitAndReveal.Reveal();
            }
            break;
        }
    }
示例#23
0
        /// <summary>
        ///     Adds a new Product to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (accountIdInput.Text.Equals("") || titleInput.Text.Equals("") || skuInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input all text boxes.");
                    accountIdInput.Focus();
                    return;
                }
                else if (!Regex.IsMatch(accountIdInput.Text, "^[0-9]*$"))
                {
                    MessageBox.Show("Please input only numerical characters into the Account ID text box.");
                    accountIdInput.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }

            ProductObject product = businessLogicLayer.CheckProductsByIDAndSku(int.Parse(accountIdInput.Text), skuInput.Text.ToLower());
            AccountObject account = businessLogicLayer.CheckAccountsByID(int.Parse(accountIdInput.Text));

            try
            {
                if (!int.Parse(accountIdInput.Text).Equals(account.account_id))
                {
                    MessageBox.Show("The Account ID provided does not exist.");
                    accountIdInput.Focus();
                    return;
                }
                else if (int.Parse(accountIdInput.Text).Equals(product.account_id) && skuInput.Text.ToLower().Equals(product.sku))
                {
                    MessageBox.Show("The Account provided already has a SKU with that name.");
                    accountIdInput.Focus();
                    return;
                }
                else
                {
                    product = businessLogicLayer.InsertNewProduct(int.Parse(accountIdInput.Text), titleInput.Text.ToLower(), skuInput.Text.ToLower());
                    MessageBox.Show(titleInput.Text + " has been added to the system.");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }
示例#24
0
 public GameContainer(int number, GameObject game, AccountObject me, AccountObject opponent, Action <GameContainer> gameExpectedMoveCallback = null, Action <GameContainer> gameCompleteCallback = null)
 {
     this.number      = number;
     this.game        = game;
     this.nextTimeOut = game.NextTimeout;
     this.me          = me;
     this.opponent    = opponent;
     gestures         = new Dictionary <SpaceTypeId, Gesture?> {
         { me.Id, null },
         { opponent.Id, null }
     };
     GameExpectedMove           = gameExpectedMoveCallback;
     GameComplete               = gameCompleteCallback;
     Repository.OnObjectUpdate += Repository_OnObjectUpdate;
 }
示例#25
0
        // GET: Admin/Account
        public ActionResult Index()
        {
            AccountObject objAcc = (AccountObject)Session[Commom.Comomconstants.USER_SESSION];

            if (objAcc == null)
            {
                return(RedirectToAction("Login"));
            }
            else if (objAcc.RoleID == 0)
            {
                return(View(new AccountBCL().GetAll()));
            }
            var lisAccount = new AccountBCL().GetAll().Where(x => x.RoleID != 0 && x.RoleID != 1 || x.AccountID == objAcc.AccountID);

            return(View(lisAccount));
        }
示例#26
0
        public Keys CheckAuthorization(AccountObject account)
        {
            if (account == null)
            {
                return(null);
            }
            var result = new Dictionary <AccountRole, KeyPair>();

            foreach (var pair in keys)
            {
                if (account.IsEquelKey(pair.Key, pair.Value))
                {
                    result[pair.Key] = pair.Value;
                }
            }
            return((result.Count > 0) ? new Keys(result) : null);
        }
示例#27
0
        public List <AccountObject> GetAll()
        {
            List <AccountObject> lst = new List <AccountObject>();
            var db   = new eTrainingScheduleEntities();
            var list = db.sp_tbl_Account_GetAll();

            foreach (var item in list)
            {
                if (item.Isdeleted == true)
                {
                    continue;
                }
                AccountObject ob = new AccountObject();
                ob.UserId = item.UserId; ob.FullName = item.FullName; ob.PassWord = item.PassWord; ob.Username = item.Username; ob.Email = item.Email; ob.Phone = item.Phone; ob.Description = item.Description; ob.Isdeleted = item.Isdeleted; ob.RoleId = item.RoleId;
                lst.Add(ob);
            }
            return(lst);
        }
示例#28
0
        public async Task <ActionResult <AtResult <AccountObjectDmListOutput> > > AccountObject_Create([FromBody] AccountObjectDmInput_Create input)
        {
            if (await CheckPermission(_context))
            {
                try
                {
                    if (!ModelState.IsValid)
                    {
                        return(new AtResult <AccountObjectDmListOutput>(AtNotify.InsertFail));
                    }
                    var account = new AccountObject
                    {
                        Id                = input.UserName,
                        AccountCode       = input.UserName,
                        UserName          = input.UserName,
                        AccountObjectName = input.AccountObjectName,
                        PassWord          = input.PassWord,
                        Phone             = input.Phone,
                        Email             = input.Email,
                        AtCreatedBy       = UserId,
                        AtRowStatus       = (int)AtRowStatus.Normal
                    };
                    var ouput = await _logicAccountObj.CreateAccountObject(account, input.ListIdDepartment, input.ListIdRole, UserId);

                    if (ouput.Item2 == AtNotify.DuplicateCode)
                    {
                        return(new AtResult <AccountObjectDmListOutput>(ouput.Item2));
                    }
                    else
                    {
                        var mapper = _mapper.Map <AccountObjectDmListOutput>(ouput.Item1);
                        return(new AtResult <AccountObjectDmListOutput>(mapper));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(new AtResult <AccountObjectDmListOutput>(AtNotify.KhongCoQuyenTruyCap));
            }
        }
示例#29
0
        private async Task <bool> PostRegister()
        {
            Busy = true;

            var request = new HttpRequestMessage(
                HttpMethod.Post, "https://altaarefapp.azurewebsites.net/api/Accounts");

            AccountObject std = new AccountObject
            {
                Email     = _emailEntry,
                Password  = _passwordEntry,
                StudentId = _studentIdEntry,
                FullName  = _fullNameEntry,
                DOB       = _dobDatePicker
            };

            var serStd = JsonConvert.SerializeObject(std);

            request.Content = new StringContent(serStd, Encoding.UTF8, "application/json");

            var response = await _client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                Busy = false;

                return(true);
            }
            else
            {
                var resCont = await response.Content.ReadAsStringAsync();

                JObject resObj = JsonConvert.DeserializeObject <dynamic>(resCont);

                var error = resObj.Value <string>("DuplicateUserName");

                ErrorMessage   = error;
                IsErrorVisible = true;

                Busy = false;

                return(false);
            }
        }
示例#30
0
    public void UpdateMatchInfo(MatchObject updatedMatch)
    {
        if (updatedMatch.ToString().Equals(match.ToString()))
        {
            return;
        }
        var currentState = MatchState;

        match = updatedMatch;
        if (!match.State.Equals(currentState))
        {
            // change state
            switch (match.State)
            {
            case ChainTypes.MatchState.Complete:
                // match complete
                if (match.MatchWinners.OrEmpty().Length == 1)
                {
                    if (match.MatchWinners[0].Equals(me.Id))
                    {
                        winner = me;
                    }
                    else
                    if (match.MatchWinners[0].Equals(opponent.Id))
                    {
                        winner = opponent;
                    }
                }
                if (!MatchComplete.IsNull())
                {
                    MatchComplete.Invoke(this);
                }
                Dispose();
                break;

            case ChainTypes.MatchState.InProgress:
                break;

            case ChainTypes.MatchState.WaitingOnPreviousMatches:
                break;
            }
        }
        OnMatchChanged.Invoke(this);
    }