Exemplo n.º 1
0
        public UserDetailsModel Login(UserDetailsModel userDetailModel)
        {
            UsersDetail userdetail = DB.UsersDetails.FirstOrDefault(u => (u.UserName == userDetailModel.userName && u.Password == userDetailModel.password));

            if (userdetail != null)
            {
                return(userDetailModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        //Add new user
        public UserDetailsModel AddNewUser(UserDetailsModel userDetailModel)
        {
            UsersDetail userdetail = DB.UsersDetails.FirstOrDefault(u => (u.UserName == userDetailModel.userName || u.Password == userDetailModel.password));

            if (userdetail == null)
            {
                UsersDetail userDetail = new UsersDetail
                {
                    FullName  = userDetailModel.fullName,
                    UserName  = userDetailModel.userName,
                    Password  = userDetailModel.password,
                    Email     = userDetailModel.email,
                    BirthDate = userDetailModel.birthDate
                };
                DB.UsersDetails.Add(userDetail);
                DB.SaveChanges();
                userDetailModel.id = userDetail.UserID;
                return(userDetailModel);
            }
            else
            {
                return(null);
            }
        }