Beispiel #1
0
 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;
         }
     }
 }
Beispiel #2
0
 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();
     }
 }
Beispiel #3
0
 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();
     }
 }
Beispiel #4
0
 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();
     }
 }
Beispiel #5
0
 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();
     }
 }
Beispiel #6
0
 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();
         }
     }
 }
Beispiel #7
0
 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();
         }
     }
 }
Beispiel #8
0
 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();
     }
 }