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 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); }