Пример #1
0
        public Status Login(string fnUsername, string password)
        {
            //check if username exists
            var acc = _accContext.Accounts.Find(fnUsername);

            if (acc == null)
            {
                return(new Status(false, "Username does not exist"));
            }

            //check if password is correct
            HashingService hs = new HashingService();

            byte[] hash = hs.GenerateHashWithSalt(acc.Salt, password);
            if (hash != acc.PasswordHash)
            {
                return(new Status(false, "Password was incorrect"));
            }

            //set Logged in status
            acc.LoggedIn = true;
            _accContext.Accounts.Attach(acc);
            _accContext.Entry(acc).Property(x => x.LoggedIn).IsModified = true;
            _accContext.SaveChanges();

            return(new Status(true, "success"));
        }
        public int AddNewAccount(AccountModel model, string email, long phonenumber)
        {
            Random r          = new Random();
            int    AccountNum = r.Next(100000000, 999999999);

            Random r1         = new Random();
            int    Ifsc       = r1.Next(100000, 999999);
            var    newAccount = new Account()
            {
                Name             = model.Name,
                Contry           = model.Contry,
                Address          = model.Address,
                City             = model.City,
                PostCode         = model.PostCode,
                Branch           = model.Branch,
                AccountType      = "Saving",
                PhoneNumber      = phonenumber,
                EmailAddress     = email,
                AccountNumber    = AccountNum,
                IFSC             = Ifsc,
                AvailableBalance = model.AvailableBalance,
            };

            _AccountContext.Account.Add(newAccount);
            _AccountContext.SaveChanges();

            return(newAccount.Id);
        }
        public ActionResult Create([Bind(Include = "vendorId,name,address,TPIN_PAN,karDataNo,email,altEmail,phone,mobilePhone,url,contactPerson,bankName,bankBranch,bankAccNo")] vendor vendor)
        {
            if (ModelState.IsValid)
            {
                vendor objVendor = new vendor();
                objVendor.name          = TrimText(vendor.name);
                objVendor.address       = TrimText(vendor.address);
                objVendor.TPIN_PAN      = TrimText(vendor.TPIN_PAN);
                objVendor.karDataNo     = TrimText(vendor.karDataNo);
                objVendor.email         = vendor.email;
                objVendor.altEmail      = vendor.altEmail;
                objVendor.phone         = TrimText(vendor.phone);
                objVendor.mobilePhone   = TrimText(vendor.mobilePhone);
                objVendor.url           = TrimText(vendor.url);
                objVendor.contactPerson = TrimText(vendor.contactPerson);
                objVendor.bankName      = TrimText(vendor.bankName);
                objVendor.bankBranch    = TrimText(vendor.bankBranch);
                objVendor.bankAccNo     = TrimText(vendor.bankAccNo);
                db.vendors.Add(objVendor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vendor));
        }
        public async Task <bool> AddCustomer(VerificationHelperModel customerModel)
        {
            try
            {
                EmailVerification emailVerification = await _context.EmailVerifications.FirstOrDefaultAsync(e => e.Email == customerModel.EmailVerification.Email).ConfigureAwait(false);

                if (emailVerification.VerificationCode != customerModel.EmailVerification.VerificationCode ||
                    emailVerification.ExpirationTime.CompareTo(DateTime.Now) ! < 0)
                {
                    return(false);
                }
                if (_context.Customers.ToList().Any(c => c.Email == customerModel.Customer.Email))
                {
                    return(false);
                }
                Customer customer = _mapper.Map <Customer>(customerModel.Customer);
                customer.Salt       = Hashing.GetSalt();
                customer.CustomerId = Guid.NewGuid();
                customer.Password   = Hashing.GenerateHash(customer.Password, customer.Salt);
                _context.Customers.Add(customer);
                _context.Accounts.Add(new Entities.Account()
                {
                    CustomerId = customer.CustomerId,
                    AccountId  = Guid.NewGuid(),
                    OpenDate   = DateTime.Now
                });
                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #5
0
        public IHttpActionResult PutProfile(int id, Profile profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != profile.Id)
            {
                return(BadRequest());
            }

            db.Entry(profile).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "baUSiNaId,baUSirsak,baUSiNo,remarks")] baUSiNa bausina)
        {
            if (ModelState.IsValid)
            {
                baUSiNa objBaUSiNa = new baUSiNa();
                string  baUSirsak  = bausina.baUSirsak.Trim();
                string  baUSiNo    = bausina.baUSiNo.Trim();
                if ((bausina.baUSiNo != null) && (bausina.baUSirsak != null))
                {
                    objBaUSiNa.baUSirsak = bausina.baUSirsak.Trim();
                    objBaUSiNa.baUSiNo   = bausina.baUSiNo.Trim();
                    objBaUSiNa.remarks   = bausina.remarks;
                }
                db.baUSiNas.Add(objBaUSiNa);
                db.SaveChanges();

                int baUSiNaId = db.baUSiNas.FirstOrDefault(m => m.baUSiNo == baUSiNo && m.baUSirsak == baUSirsak).baUSiNaId;
                if (db.setNumbers.FirstOrDefault(m => m.baUSiNaId == baUSiNaId && m.faramName == "JornalEntries") == null)
                {
                    db.setNumbers.Add(new setNumber {
                        faramName = "JornalEntries", number = 1, baUSiNaId = baUSiNaId
                    });
                }
                if (db.setNumbers.FirstOrDefault(m => m.baUSiNaId == baUSiNaId && m.faramName == "BhuktaniAdesh") == null)
                {
                    db.setNumbers.Add(new setNumber {
                        faramName = "BhuktaniAdesh", number = 1, baUSiNaId = baUSiNaId
                    });
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bausina));
        }
        public ActionResult Create(List <arthaBudget> arthabudget, FormCollection col)
        {
            DateTime nepDate;
            int      mn   = Convert.ToInt32(col["month"]);
            int      fyId = Convert.ToInt32(col["fyId"]);
            //var objFiscalYear = db.fisYears.Find(fyId);
            string year = getYear(fyId, mn);

            nepDate = Convert.ToDateTime(col["nepDate"]);
            var objArtha = db.arthaBudgets.FirstOrDefault(m => (m.year == year) && (m.monthIndex == mn));

            if (ModelState.IsValid)
            {
                foreach (var item in arthabudget)
                {
                    arthaBudget artha = new arthaBudget();
                    artha.employeeName = TrimText(item.employeeName);
                    artha.khaSiNa3     = item.khaSiNa3;
                    artha.khaSiNa4     = item.khaSiNa4;
                    artha.nepDate      = nepDate;
                    artha.year         = year;
                    artha.month        = ((month)mn).ToString();
                    artha.monthIndex   = mn;
                    artha.fyId         = Convert.ToInt32(col["fyId"]);
                    db.arthaBudgets.Add(artha);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ErrorMessage = "Record Not Inserted.Please Try Again";
            ViewBag.fyId         = new SelectList(db.fisYears, "fyId", "nepFy", fyId);
            return(View(arthabudget));
        }
Пример #8
0
        public ActionResult Register([Bind(Include = "username, password, email, confirmPassword")] RegisterViewModel user)
        {
            //Map RegisterViewModel to Account model
            Account model = new Account()
            {
                id              = user.id,
                username        = user.username,
                email           = user.email,
                password        = user.password,
                confirmPassword = user.confirmPassword,
            };

            if (ModelState.IsValid)
            {
                db.user.Add(model);
                db.SaveChanges();
                ModelState.Clear();

                ViewBag.Message = user.username + " " + "has been successfully registered. Redirecting you to the home page...";
            }
            else
            {
                ModelState.AddModelError("", "We could not register your account.");
            }

            return(View(user));
        }
Пример #9
0
        public IActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                User NewUser = new User
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email,
                    Password  = model.Password
                };
                PasswordHasher <User> Hasher = new PasswordHasher <User>();
                NewUser.Password = Hasher.HashPassword(NewUser, NewUser.Password);

                _context.Users.Add(NewUser);
                _context.SaveChanges();

                Account NewAccount = new Account
                {
                    Balance = 0,
                    UserID  = NewUser.UserID
                };
                _context.Accounts.Add(NewAccount);
                _context.SaveChanges();
                HttpContext.Session.SetInt32("CurrentUserID", NewUser.UserID);

                return(RedirectToAction("Account", "Bank", new { userID = NewUser.UserID }));
            }
            return(View("Index"));
        }
Пример #10
0
        public IActionResult Transaction(float transact, int AcId, float Balance)
        {
            System.Console.WriteLine($"Line 49, Transaction {transact},{AcId},{Balance}");
            int?Id = HttpContext.Session.GetInt32("UserId");

            ViewBag.Errors = new List <string>();
            if ((transact + Balance) >= 0)
            {
                // System.Console.WriteLine($"Line 38, ACCCont{transact}{AcId}");
                // Accounts RetrievedAccount = _context.Accounts.SingleOrDefault(account => account.AccountsId == AcId);
                // RetrievedAccount.Transaction=transact;
                // RetrievedAccount.CurrentBalance= Balance + transact;
                // RetrievedAccount.UpdatedAt=DateTime.Now;
                // _context.SaveChanges();
                float    total      = Balance + (transact);
                Accounts newAccount = new Accounts {
                    CurrentBalance = total,
                    Transaction    = (float)transact,
                    CreatedAt      = DateTime.Now,
                    UpdatedAt      = DateTime.Now,
                };
                System.Console.WriteLine($"Line 66,Transaction{newAccount.CurrentBalance}");
                _context.Accounts.Add(newAccount);
                _context.SaveChanges();
                Accounts createdAccount = _context.Accounts.Last();
                if (Id != null)
                {
                    JointAccounts newJoint = new JointAccounts {
                        UsersId    = (int)Id,
                        AccountsId = createdAccount.AccountsId
                    };
                    _context.JointAccounts.Add(newJoint);
                    _context.SaveChanges();
                }
                ;
            }
            else
            {
                ViewBag.Errors.Add("Insufficent funds!");
            }

            List <Users> PopulatedUserAccounts = new List <Users> ();

            PopulatedUserAccounts = GetPopulatedUser();



            var accounts = from useraccounts in PopulatedUserAccounts
                           from account in useraccounts.JointAccounts
                           orderby account.Accounts.CreatedAt descending
                           select account;

            ViewBag.CurrentBalance = accounts.First();
            ViewBag.JointAccounts  = accounts;
            ViewBag.user           = PopulatedUserAccounts;

            return(View("Show"));
        }
Пример #11
0
        public IActionResult Register(Users newUser)
        {
            System.Console.WriteLine(ModelState.IsValid);
            if (ModelState.IsValid)
            {
                System.Console.WriteLine(newUser.FirstName);
                Users createdUser = new Users {
                    FirstName = newUser.FirstName,
                    LastName  = newUser.LastName,
                    Email     = newUser.Email,
                    Password  = newUser.Password,
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                };
                _context.Users.Add(createdUser);
                _context.SaveChanges();
                Users ReturnedUser = _context.Users.SingleOrDefault(user => user.Email == createdUser.Email);
                System.Console.WriteLine($"Email from returned {ReturnedUser.Email}");
                HttpContext.Session.SetInt32("UserId", (int)ReturnedUser.UsersId);
                // Users populatedUser=GetUsers();
                List <Users> populatedUsers = GetPopulatedUser();

                // Create an Account
                if (populatedUsers[0].JointAccounts.Count == 0)
                {
                    Accounts newAccount = new Accounts {
                        CurrentBalance = 50,
                        Transaction    = 50,
                        CreatedAt      = DateTime.Now,
                        UpdatedAt      = DateTime.Now,
                    };
                    _context.Accounts.Add(newAccount);
                    _context.SaveChanges();
                    Accounts createdAccount = _context.Accounts.Last();
                    int?     jId            = HttpContext.Session.GetInt32("UserId");
                    System.Console.WriteLine($"JIIIIIIIIIDDDDDDDdd    {jId}");
                    if (jId != null)
                    {
                        JointAccounts newJoint = new JointAccounts {
                            UsersId    = (int)jId,
                            AccountsId = createdAccount.AccountsId
                        };
                        _context.JointAccounts.Add(newJoint);
                        _context.SaveChanges();
                    }
                    ;

                    System.Console.WriteLine($"Created account Id{createdAccount.AccountsId}");
                }
                return(RedirectToAction("Show", "Account"));
            }
            else
            {
                ViewBag.Errors = ModelState.Values;
                return(View("Registration"));
            }
        }
Пример #12
0
 public ActionResult Create(SysUser user)
 {
     if (ModelState.IsValid)
     {
         db.SysUsers.Add(user);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #13
0
        public bool IsValidRegistration(TextBlock textBlock)
        {
            Account account = new Account(Username.ToLower(), Password, Firstname, Lastname);

            if (string.IsNullOrEmpty(Age) || string.IsNullOrWhiteSpace(Age))
            {
                if (IsValidPassword(textBlock).Item1)
                {
                    if (!AccountDataService.DoesPlayerExistWithName(context, account.Username))
                    {
                        textBlock.Text       = "Successfully created account";
                        textBlock.Visibility = Visibility.Visible;
                        context.Accounts.Add(account);
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        textBlock.Text       = "Username already exists";
                        textBlock.Visibility = Visibility.Visible;
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                account = new Account(Username.ToLower(), Password, Firstname, Lastname, int.Parse(Age));

                if (IsValidPassword(textBlock).Item1)
                {
                    if (!AccountDataService.DoesPlayerExistWithName(context, account.Username))
                    {
                        textBlock.Text       = "Creating Account";
                        textBlock.Visibility = Visibility.Visible;
                        context.Accounts.Add(account);
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        textBlock.Text       = "Username already exists";
                        textBlock.Visibility = Visibility.Visible;
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
 public ActionResult Create(List <byehora> byehoras)
 {
     try
     {
         if (ModelState.IsValid)
         {
             foreach (var item in byehoras)
             {
                 if (item.hisabNo == null)
                 {
                     byehora objByehora = new byehora();
                     objByehora.byehoraName = TrimText(item.byehoraName);
                     objByehora.hisabNo     = TrimText(item.hisabNo);
                     objByehora.remarks     = TrimText(item.remarks);
                     objByehora.khaSiNaId   = null;
                     db.byehoras.Add(objByehora);
                     db.SaveChanges();
                 }
                 else
                 {
                     string hisabNo    = TrimText(item.hisabNo);
                     var    objKhaSiNa = db.khaSiNas.FirstOrDefault(m => m.khaSiNo == hisabNo);
                     if (objKhaSiNa == null)
                     {
                         byehora objByehora = new byehora();
                         objByehora.byehoraName = TrimText(item.byehoraName);
                         objByehora.hisabNo     = TrimText(item.hisabNo);
                         objByehora.remarks     = TrimText(item.remarks);
                         objByehora.khaSiNaId   = null;
                         db.byehoras.Add(objByehora);
                         db.SaveChanges();
                     }
                     else
                     {
                         byehora objByehora = new byehora();
                         objByehora.byehoraName = TrimText(item.byehoraName);
                         objByehora.hisabNo     = TrimText(item.hisabNo);
                         objByehora.remarks     = TrimText(item.remarks);
                         objByehora.khaSiNaId   = objKhaSiNa.khaSiNaId;
                         db.byehoras.Add(objByehora);
                         db.SaveChanges();
                     }
                 }
             }
         }
         ViewBag.Message = "Record Inserted Successfully";
         return(RedirectToAction("index", "Byehora"));
     }
     catch
     {
         ViewBag.ErrorMessage = "Error! Please Try Again";
         return(View(byehoras));
     }
 }
Пример #15
0
        public ActionResult Create([Bind(Include = "ID,RoleName,RoleDesc")] SysRole sysRole)
        {
            if (ModelState.IsValid)
            {
                db.SysRoles.Add(sysRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sysRole));
        }
Пример #16
0
        public ActionResult Create([Bind(Include = "Id,AccountNumber,CreationDate,Balance")] Account account)
        {
            if (ModelState.IsValid)
            {
                db.Accounts.Add(account);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(account));
        }
Пример #17
0
        public ActionResult Create([Bind(Include = "setNumberId,faramName,number")] setNumber setnumber)
        {
            if (ModelState.IsValid)
            {
                db.setNumbers.Add(setnumber);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(setnumber));
        }
Пример #18
0
 public ActionResult Create(SysUser sysUser)
 {
     if (ModelState.IsValid)
     {
         sysUser.CreateDate = DateTime.Now;
         db.SysUsers.Add(sysUser);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #19
0
        public ActionResult Create([Bind(Include = "Id,Kind")] OperationKind operationKind)
        {
            if (ModelState.IsValid)
            {
                db.OperationKinds.Add(operationKind);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(operationKind));
        }
Пример #20
0
        public ActionResult Create([Bind(Include = "bhuktaniPauneId,pauneKoNaam,code,remarks")] bhuktaniPaune bhuktanipaune)
        {
            if (ModelState.IsValid)
            {
                db.bhuktaniPaunes.Add(bhuktanipaune);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bhuktanipaune));
        }
        public ActionResult Create([Bind(Include = "Id,DepartmentName,DepartmentDesc")] SysDepartment sysDepartment)
        {
            if (ModelState.IsValid)
            {
                db.SysDepartments.Add(sysDepartment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sysDepartment));
        }
Пример #22
0
        public ActionResult Create([Bind(Include = "ID,UserName,PassWord,Email,CreateDate,SysDepartmentId")] SysUser sysUser)
        {
            if (ModelState.IsValid)
            {
                db.SysUsers.Add(sysUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SysDepartmentId = new SelectList(db.SysDepartments, "Id", "DepartmentName", sysUser.SysDepartmentId);
            return(View(sysUser));
        }
Пример #23
0
        public ActionResult Create([Bind(Include = "Id,StartDate,Years,LoanAmount,RepaymentAmount,AccountId")] Credit credit)
        {
            if (ModelState.IsValid)
            {
                db.Credits.Add(credit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId = new SelectList(db.Accounts, "Id", "AccountNumber", credit.AccountId);
            return(View(credit));
        }
Пример #24
0
        public ActionResult Create([Bind(Include = "Id,Income,FatherName,MotherName,MotherMaidenName,LoanAmount,Status,AccountId")] Proposal proposal)
        {
            if (ModelState.IsValid)
            {
                db.Proposals.Add(proposal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId = new SelectList(db.Accounts, "Id", "AccountNumber", proposal.AccountId);
            return(View(proposal));
        }
Пример #25
0
        public IActionResult CreateAccount(int id)
        {
            Account newAccount = new Account
            {
                AccountBalance = 0,
                UserId         = id
            };

            _context.Accounts.Add(newAccount);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Account"));
        }
Пример #26
0
        public ActionResult Create([Bind(Include = "Id,AccountId,OperationKindId,Title,Amount,Date,ToAccountNumber,Description")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId       = new SelectList(db.Accounts, "Id", "AccountNumber", transaction.AccountId);
            ViewBag.OperationKindId = new SelectList(db.OperationKinds, "Id", "Kind", transaction.OperationKindId);
            return(View(transaction));
        }
Пример #27
0
        public ActionResult Create([Bind(Include = "ID,SysUserID,SysRoleID")] SysUserRole sysUserRole)
        {
            if (ModelState.IsValid)
            {
                db.SysUserRoles.Add(sysUserRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SysRoleID = new SelectList(db.SysRoles, "ID", "RoleName", sysUserRole.SysRoleID);
            ViewBag.SysUserID = new SelectList(db.SysUsers, "ID", "UserName", sysUserRole.SysUserID);
            return(View(sysUserRole));
        }
Пример #28
0
 public BankAccount CreateBA(BankAccount BA)
 {
     if (_accountContext.BankAccounts.Any(x => x.AccountNumber == BA.AccountNumber))
     {
         throw new ApplicationException("This BA number is already taken!");
     }
     BA.AccountType      = "Student";
     BA.RealBalance      = 50000;
     BA.AvailableBalance = 0;
     _accountContext.Add(BA);
     _accountContext.SaveChanges();
     return(BA);
 }
        /// <summary>
        /// Adds a claim to the user
        /// </summary>
        /// <param name="obj">
        /// - UserName
        /// - ClaimID
        /// </param>
        /// <returns>
        /// - TRUE: Succeeds to add UserClaim
        /// - FALSE: Fails to add UserClaim
        /// </returns>
        public ResponseDTO <Boolean> AddUserClaims(UserAccessDTO obj)
        {
            // Find user based off Username
            var foundUser = (from account in db.Credentials
                             where account.UserName == obj.UserName
                             select account).FirstOrDefault();
            // Creating Response
            ResponseDTO <Boolean> response = new ResponseDTO <bool>();

            if (foundUser == null)
            {
                response.IsSuccessful = false;
                response.Data         = false;
                return(response);
            }
            else
            {
                using (var dbTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        for (int i = 0; i < obj.UserClaims.Count; i++)
                        {
                            UserClaims newUserClaim = new UserClaims()
                            {
                                ClaimType  = obj.UserClaims[i].Type,
                                ClaimValue = obj.UserClaims[i].Value,
                                UserID     = foundUser.UserID
                            };
                            db.UserClaims.Add(newUserClaim);
                            db.SaveChanges();
                        }
                        dbTransaction.Commit();
                        response.IsSuccessful = true;
                        response.Data         = true;
                        return(response);
                    }
                    catch (Exception)
                    {
                        dbTransaction.Rollback();
                        response.IsSuccessful = false;
                        response.Data         = false;
                        response.Messages     = new List <string> {
                            "Error occured while adding Claims."
                        };
                        return(response);
                    }
                }
            }
        }
Пример #30
0
        public ActionResult Details([Bind(Include = "Id")] Profile profile)
        {
            Profile            prof = db.Profiles.Find(profile.Id);
            HttpPostedFileBase file = Request.Files["photoFile"];

            if (file != null && file.ContentLength > 0)
            {
                prof.Photo = file.FileName;
                file.SaveAs(HttpContext.Server.MapPath("~/Photos/" + file.FileName));
            }
            db.Entry(prof).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Details"));
        }