public IHttpActionResult PutSeekerProfile(int id, SeekerProfile seekerProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != seekerProfile.SeekerProfileId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetSeekerProfile(int id)
        {
            SeekerProfile seekerProfile = db.SeekerProfiles.Find(id);

            if (seekerProfile == null)
            {
                return(NotFound());
            }

            return(Ok(seekerProfile));
        }
        public IHttpActionResult PostSeekerProfile(SeekerProfile seekerProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SeekerProfiles.Add(seekerProfile);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = seekerProfile.SeekerProfileId }, seekerProfile));
        }
        public HttpResponseMessage Post([FromBody] SignupInfo info)
        {
            JinderDBConnection dbContext = new JinderDBConnection();
            var usersTable = dbContext.JinderUsers;

            JinderUser jinderUser = (from user in usersTable
                                     where user.Username == info.Username
                                     select user).FirstOrDefault <JinderUser>();

            HttpResponseMessage message = new HttpResponseMessage();

            if (jinderUser != null)
            {
                message.StatusCode = HttpStatusCode.Conflict;
                message.Content    = new StringContent("Username: "******" is already registered.");

                return(message);
            }

            JinderUser newUser = new JinderUser();

            newUser.Username       = info.Username;
            newUser.Password       = info.Password;
            newUser.FullName       = info.FullName;
            newUser.DateOfBirth    = info.DateOfBirth;
            newUser.ProfilePicture = info.ProfilePicture;
            newUser.Gender         = info.Gender;
            newUser.Address        = info.Address;
            newUser.UserType       = info.UserType;

            usersTable.Add(newUser);
            dbContext.SaveChanges();

            if (info.UserType == "seeker")
            {
                SeekerProfile newSeekerProfile = new SeekerProfile();
                newSeekerProfile.JinderUserId  = newUser.JinderUserId;
                newSeekerProfile.Education     = info.Education;
                newSeekerProfile.Experience    = info.Experience;
                newSeekerProfile.Skills        = info.Skills;
                newSeekerProfile.Certification = info.Certification;

                var seekersTable = dbContext.SeekerProfiles;
                seekersTable.Add(newSeekerProfile);

                dbContext.SaveChanges();
            }

            message.StatusCode = HttpStatusCode.Created;
            return(message);
        }
        public HttpResponseMessage PostNewSeekerUser(SeekerUserModel jinderSeekerUser)
        {
            JinderDBEntities dbContext = new JinderDBEntities();
            var usersTable             = dbContext.JinderUsers;
            var SeekersTable           = dbContext.SeekerProfiles;

            HttpResponseMessage message = new HttpResponseMessage();

            JinderUser jinderuser = (from user in usersTable
                                     where user.username == jinderSeekerUser.username
                                     select user).FirstOrDefault <JinderUser>();

            if (jinderuser != null)
            {
                message.StatusCode = HttpStatusCode.Conflict;
                return(message);
            }
            else
            {
                JinderUser user = new JinderUser();

                user.FullName    = jinderSeekerUser.FullName;
                user.DateOfBirth = jinderSeekerUser.DateOfBirth;
                user.Gender      = jinderSeekerUser.Gender;
                user.Address     = jinderSeekerUser.Address;
                user.UserType    = jinderSeekerUser.UserType;
                user.username    = jinderSeekerUser.username;
                user.password    = jinderSeekerUser.password;


                usersTable.Add(user);
                dbContext.SaveChanges();

                SeekerProfile seekerUser = new SeekerProfile();

                seekerUser.JinderUserId  = user.JinderUserId;
                seekerUser.Certification = jinderSeekerUser.Certification;
                seekerUser.Education     = jinderSeekerUser.Education;
                seekerUser.Experience    = jinderSeekerUser.Experience;
                seekerUser.Skills        = jinderSeekerUser.Skills;

                SeekersTable.Add(seekerUser);
                dbContext.SaveChanges();


                message.StatusCode = HttpStatusCode.OK;

                return(message);
            }
        }
        public IHttpActionResult DeleteSeekerProfile(int id)
        {
            SeekerProfile seekerProfile = db.SeekerProfiles.Find(id);

            if (seekerProfile == null)
            {
                return(NotFound());
            }

            db.SeekerProfiles.Remove(seekerProfile);
            db.SaveChanges();

            return(Ok(seekerProfile));
        }
Beispiel #7
0
        public HttpResponseMessage PostNewSeekerUser(SeekerUserModel jinderSeekerUser)
        {
            JinderDBEntities dbContext = new JinderDBEntities();
            var usersTable             = dbContext.JinderUsers;
            var SeekersTable           = dbContext.SeekerProfiles;

            HttpResponseMessage message = new HttpResponseMessage();

            //if(usersTable.Find(infoUser.JinderUserId) != null)
            //{
            //    message.StatusCode = HttpStatusCode.Conflict;
            //    message.Content = new StringContent("Username: "******" is already registered");
            //    return message;
            //}

            JinderUser user = new JinderUser();

            user.FullName    = jinderSeekerUser.FullName;
            user.DateOfBirth = jinderSeekerUser.DateOfBirth;
            user.Gender      = jinderSeekerUser.Gender;
            user.Address     = jinderSeekerUser.Address;
            user.UserType    = jinderSeekerUser.UserType;
            user.username    = jinderSeekerUser.username;
            user.password    = jinderSeekerUser.password;



            usersTable.Add(user);
            dbContext.SaveChanges();

            SeekerProfile seekerUser = new SeekerProfile();

            seekerUser.JinderUserId  = user.JinderUserId;
            seekerUser.Certification = jinderSeekerUser.Certification;
            seekerUser.Education     = jinderSeekerUser.Education;
            seekerUser.Experience    = jinderSeekerUser.Experience;
            seekerUser.Skills        = jinderSeekerUser.Skills;

            SeekersTable.Add(seekerUser);
            dbContext.SaveChanges();

            //message.Content = new StringContent("name " + name);
            //message.Content = new StringContent("user saved");


            return(message);
        }
Beispiel #8
0
        public static JinderSeeker getJinderSeeker(JinderUser user)
        {
            if (user.UserType != "seeker")
            {
                throw new Exception("Provided JinderUser: "******" is not a seeker!");
            }

            JinderDBConnection dbContext     = new JinderDBConnection();
            SeekerProfile      seekerProfile = (from profile in dbContext.SeekerProfiles
                                                where profile.JinderUserId == user.JinderUserId
                                                select profile).FirstOrDefault <SeekerProfile>();

            if (seekerProfile == null)
            {
                throw new Exception("Could not find a SeekerProfile for JinderUser: " + user.Username);
            }

            JinderSeeker jinderSeeker = new JinderSeeker();

            jinderSeeker.JinderUserId   = user.JinderUserId;
            jinderSeeker.FullName       = user.FullName;
            jinderSeeker.DateOfBirth    = user.DateOfBirth;
            jinderSeeker.ProfilePicture = user.ProfilePicture;
            jinderSeeker.Gender         = user.Gender;
            jinderSeeker.Address        = user.Address;
            jinderSeeker.UserType       = user.UserType;
            jinderSeeker.Password       = user.Password;
            jinderSeeker.Username       = user.Username;

            jinderSeeker.SeekerProfileId = seekerProfile.SeekerProfileId;
            jinderSeeker.Education       = seekerProfile.Education;
            jinderSeeker.Experience      = seekerProfile.Experience;
            jinderSeeker.Skills          = seekerProfile.Skills;
            jinderSeeker.Certification   = seekerProfile.Certification;

            return(jinderSeeker);
        }