public void UpdateUser(User user) { using (var ctx = new PlatineContext()) { ctx.Entry(user).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public void AddExperience(Experience experience) { using (var ctx = new PlatineContext()) { ctx.Experiences.Add(experience); ctx.SaveChanges(); } }
public void AddSkillName(SkillName skillName) { using (var ctx = new PlatineContext()) { ctx.SkillNames.Add(skillName); ctx.SaveChanges(); } }
public void AddSkill(Skill skill) { using (var ctx = new PlatineContext()) { ctx.Skills.Add(skill); ctx.SaveChanges(); } }
public void UpdateEducation(Education education) { using (var ctx = new PlatineContext()) { ctx.Entry(education).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public void AddEducation(Education education) { using (var ctx = new PlatineContext()) { ctx.Educations.Add(education); ctx.SaveChanges(); } }
public void DeleteEducation(Guid id) { using (var ctx = new PlatineContext()) { var query = ctx.Educations.SingleOrDefault(e => e.Id.Equals(id)); ctx.Educations.Remove(query); ctx.SaveChanges(); } }
public void UpdateExperience(Experience experience, Guid userId) { using (var ctx = new PlatineContext()) { if (!experience.UserId.Equals(userId)) { throw new NotAllowedException(); } ctx.Entry(experience).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public void Register(User user) { using (var ctx = new PlatineContext()) { var query = ctx.Users.SingleOrDefault(u => u.Login.Equals(user.Login)); if (query != null) { throw new AlreadyExistException(); } ctx.Users.Add(user); ctx.SaveChanges(); }; }
public void DeleteUserById(Guid id) { using (var ctx = new PlatineContext()) { User u = ctx.Users.SingleOrDefault(e => e.Id.Equals(id)); if (u == null) { throw new MissingException("User " + id); } ctx.Users.Remove(u); ctx.SaveChanges(); } }
public void DeleteExperience(Guid id, Guid userId) { using (var ctx = new PlatineContext()) { var query = ctx.Experiences.SingleOrDefault(e => e.Id.Equals(id)); if (query == null) { throw new MissingException("Experience"); } if (!query.UserId.Equals(userId)) { throw new NotAllowedException(); } ctx.Experiences.Remove(query); ctx.SaveChanges(); } }