public void EditProfile(Profile profile) { using (LearnContext lc = new LearnContext()) { try { Profile profile1 = lc.Profiles.Find(profile.Id); profile1.Description = profile.Description; profile1.Image = profile.Image; profile1.PackagePlan.CostPer3Days = profile.PackagePlan.CostPer3Days; profile1.PackagePlan.CostPerDay = profile.PackagePlan.CostPerDay; profile1.PackagePlan.CostPerHour = profile.PackagePlan.CostPerHour; profile1.Name = profile.Name; profile1.CategoryId = profile.CategoryId; profile1.SubcategoryId = profile.SubcategoryId; lc.Entry(profile1.PackagePlan).State = EntityState.Modified; lc.Entry(profile1).State = EntityState.Modified; lc.SaveChanges(); } catch (Exception) { throw; } } }
public void AddProfile(Profile profile) { using (LearnContext lc = new LearnContext()) { lc.Entry(profile.Teacher).State = EntityState.Unchanged; lc.Entry(profile.ProfileStatus).State = EntityState.Unchanged; lc.Profiles.Add(profile); lc.SaveChanges(); } }
public void AddRequest(Request request) { using (LearnContext lc = new LearnContext()) { lc.Entry(request.RequestStatus).State = EntityState.Unchanged; lc.Entry(request.Student).State = EntityState.Unchanged; lc.Entry(request.Teacher).State = EntityState.Unchanged; lc.Requests.Add(request); lc.SaveChanges(); } }
public void AddMessage(RequestMessage requestMessage) { using (LearnContext lc = new LearnContext()) { lc.Entry(requestMessage.Sender).State = EntityState.Unchanged; lc.Entry(requestMessage.Reciever).State = EntityState.Unchanged; lc.Entry(requestMessage.Request).State = EntityState.Unchanged; lc.RequestMessages.Add(requestMessage); lc.SaveChanges(); } }
public void AddUser(User user) { using (LearnContext lc = new LearnContext()) { lc.Entry(user.Country).State = EntityState.Unchanged; lc.Entry(user.Role).State = EntityState.Unchanged; lc.Entry(user.AccountStatus).State = EntityState.Unchanged; lc.Users.Add(user); lc.SaveChanges(); } }
public void DeleteTeacher(User user) { using (LearnContext lc = new LearnContext()) { try { lc.Entry(user.AccountStatus).State = EntityState.Modified; lc.Entry(user).State = EntityState.Modified; lc.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); } } }
public void UpdateRequest(Request request) { using (LearnContext lc = new LearnContext()) { try { lc.Entry(request.RequestStatus).State = EntityState.Modified; lc.Entry(request).State = EntityState.Modified; lc.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); } } }
public void AddProfilePicture(User user) { using (LearnContext lc = new LearnContext()) { User u = lc.Users.Find(user.Id); u.Image = user.Image; lc.Entry(u).State = EntityState.Modified; lc.SaveChanges(); } }