Пример #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);
            }
        }
        public HttpResponseMessage GetUserID(string username)
        {
            try
            {
                UserDetailsModel userid = userdetailslogic.GetUserID(username);

                return(Request.CreateResponse(HttpStatusCode.OK, userid));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
 public HttpResponseMessage Login(UserDetailsModel userDetailModel)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             List <PropErrors> errorList = ErrorExtractor.ExtractError(ModelState);
             return(Request.CreateResponse(HttpStatusCode.BadRequest, errorList));//badrequest = 400
         }
         else
         {
             UserDetailsModel userDetail = userdetailslogic.Login(userDetailModel);
             return(Request.CreateResponse(HttpStatusCode.Created, userDetail));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
Пример #4
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);
            }
        }