Beispiel #1
0
        public int SaveUser(Domain.User userModel)
        {
            User efUser = new User();

            if (userModel.UserId == 0)
            {
                demoDBContext.User.Add(efUser);
            }
            else
            {
                efUser = demoDBContext.User.Where(x => x.UserId == efUser.UserId).FirstOrDefault();
            }

            efUser.FirstName    = userModel.FirstName;
            efUser.LastName     = userModel.LastName;
            efUser.Email        = userModel.Email;
            efUser.Phone        = userModel.Phone;
            efUser.BirthDate    = userModel.BirthDate;
            efUser.Gender       = userModel.Gender;
            efUser.AddressId    = userModel.AddressId;
            efUser.DepartmentId = userModel.DepartmentId;
            efUser.RoleId       = userModel.RoleId;
            efUser.Username     = userModel.Username;
            efUser.Password     = userModel.Password;
            efUser.ProfileImage = userModel.ProfileImage;

            demoDBContext.SaveChanges();

            return(efUser.UserId);
        }
Beispiel #2
0
        public Domain.User GetUserByUserNamePassword(Domain.User UserModel)
        {
            Domain.User User = new Domain.User();

            try
            {
                User = demoDBContext.User
                       .Where(x => x.Username == UserModel.Username && x.Password == UserModel.Password)
                       .Select(x => new Domain.User()
                {
                    UserId       = x.UserId,
                    FirstName    = x.FirstName,
                    LastName     = x.LastName,
                    Email        = x.Email,
                    Phone        = x.Phone,
                    BirthDate    = x.BirthDate,
                    Gender       = x.Gender,
                    AddressId    = x.AddressId,
                    DepartmentId = x.DepartmentId,
                    RoleId       = x.RoleId,
                    Username     = x.Username,
                    Password     = x.Password,
                    ProfileImage = x.ProfileImage
                })
                       .FirstOrDefault();
            }
            catch (Exception ex)
            {
            }

            return(User);
        }
Beispiel #3
0
 public ActionResult Edit(int id, FormCollection formCollection)
 {
     try
     {
         var user = new User();
         UpdateModel(user, formCollection);
         repository.Update(user);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Beispiel #4
0
        public Domain.User GetUserById(int userId)
        {
            Domain.User user = new Domain.User();
            user = (from User u in demoDBContext.User
                    join Address a in demoDBContext.Address on u.AddressId equals a.AddressId
                    where u.UserId == userId
                    select new Domain.User()
            {
                FirstName = u.FirstName,
                LastName = u.LastName,
                Email = u.Email,
                Phone = u.Phone,
                BirthDate = u.BirthDate,
                Gender = u.Gender,
                AddressId = u.AddressId,
                DepartmentId = u.DepartmentId,
                RoleId = u.RoleId,
                Username = u.Username,
                Password = u.Password,
                ProfileImage = u.ProfileImage,

                Address = new Domain.Address()
                {
                    AddressId = a.AddressId,
                    CityId = a.CityId,
                    CountryId = a.CountryId,
                    HouseOfficeNo = a.HouseOfficeNo,
                    StateId = a.StateId,
                    Street1 = a.Street1,
                    Street2 = a.Street2,
                    ZipCode = a.ZipCode
                }
            }).FirstOrDefault();

            return(user);
        }
 public UserTranscationModel(User user, List<Transaction> transactions, int averageAmount)
 {
     User = user;
     Transactions = transactions;
     AverageAmount = averageAmount;
 }