Ejemplo n.º 1
0
        public async Task <MobileResult> UpdateHomeModel(HomeModel newModel)
        {
            var mobileResult = new MobileResult();

            try
            {
                var model = await _context.HomeModels.FirstAsync(a => a.HomeID == newModel.HomeID);


                mySecurity locker     = new mySecurity();
                string     salt       = locker.HashCreate();
                string     encryptKey = locker.HashCreate(newModel.HomePassword, salt);

                newModel.HomePassword = encryptKey;

                model = newModel;

                await SaveAsync();

                mobileResult.Data    = null;
                mobileResult.Message = "Başarılı";
                mobileResult.Result  = true;
            }
            catch (Exception e)
            {
                mobileResult.Data    = null;
                mobileResult.Message = e.Message;
                mobileResult.Result  = false;
            }

            return(mobileResult);
        }
Ejemplo n.º 2
0
        public async Task <MobileResult> UpdateUserModel(UserModel newModel)
        {
            var mobileResult = new MobileResult();

            try
            {
                UserModel model = await _context.UserModels.FindAsync(newModel.UserID);

                if (model.UserName == newModel.UserName)
                {
                    model = newModel;

                    mySecurity locker     = new mySecurity();
                    string     salt       = locker.HashCreate();
                    string     encryptKey = locker.HashCreate(model.UserPassword, salt);

                    model.UserPassword = encryptKey;

                    await SaveAsync();

                    mobileResult.Data    = null;
                    mobileResult.Result  = true;
                    mobileResult.Message = "Başarılı";

                    return(mobileResult);
                }
                else
                {
                    if (await isExistUsername(newModel.UserName))
                    {
                        mobileResult.Data    = null;
                        mobileResult.Result  = false;
                        mobileResult.Message = "Aynı kullanıcı adı mevcut";
                        return(mobileResult);
                    }
                    else
                    {
                        model = newModel;

                        mySecurity locker     = new mySecurity();
                        string     salt       = locker.HashCreate();
                        string     encryptKey = locker.HashCreate(model.UserPassword, salt);

                        model.UserPassword = encryptKey;

                        await SaveAsync();

                        mobileResult.Data    = null;
                        mobileResult.Result  = true;
                        mobileResult.Message = "Başarılı";

                        return(mobileResult);
                    }
                }
            }
            catch (Exception e)
            {
                mobileResult.Data    = null;
                mobileResult.Result  = false;
                mobileResult.Message = e.Message;
                return(mobileResult);
            }
        }