0% found this document useful (0 votes)
67 views1 page

Student Management CRUD Interface

The document defines classes for a Student and Course. An interface IMaintainable is created to abstract CRUD operations on an entity. A StudentManager class implements IMaintainable for Students and performs CRUD operations by calling a data access layer. An issue with the Update method is discussed, where inheriting from Student in StudentManager is proposed so the Student object's properties can be updated directly.

Uploaded by

eimher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views1 page

Student Management CRUD Interface

The document defines classes for a Student and Course. An interface IMaintainable is created to abstract CRUD operations on an entity. A StudentManager class implements IMaintainable for Students and performs CRUD operations by calling a data access layer. An issue with the Update method is discussed, where inheriting from Student in StudentManager is proposed so the Student object's properties can be updated directly.

Uploaded by

eimher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

public class Student

 {
    public string StudentId { get; set; }
    public string StudentName { get; set; }
    public Course StudentCourse { get; set; }
 }

 public class Course


 {
    public string CourseCode { get; set; }
    public string CourseDesc { get; set; }
 }

I created an CRUD Interface to abstract the object's operations

public interface IMaintanable<T>


{
    string Create(T obj);
    T Retrieve(string key);
    void Update(T obj);
    void Delete(string key);
}

And then a component that manages the Entity and its operations by implementing the interface

public class StudentManager : IMaintainable<Student>


{
    public void Create(Student obj)
  {
        // inserts record in the DB via DAL
  }

    public Student Retrieve(string userId)


    {        // retrieveds record from the DB via DAL    }

   public void Update(Student obj)


    {        // should update the record in the DB    }

    public void Delete(string userId)


    {        // deletes record from the DB    }
}

    public void Button_SaveStudent(Event args, object sender)


  {
        Student student = new Student()
    {
           Student.Id = "1", Student.Name = "Cnillincy"
        }        new StudentManager().Create(student);  
     }

as you can see, there is quite an abnormalities on the update method

    public void Update()


    {        // should update the record in the DB    }

what should this method have to update the objects property? should I inherit the Student?
    public class StudentManager : Student , IMaintainable<Student>
  {
        public void Update()
        {            //update record via DAL         }
  }

    public void Button_SaveStudent(Event args, object sender)


  {
        Student student = new StudentManager();
        student.StudentId = "1";
        student.StudentName = "Cnillincy"
        student.Update()
  }

You might also like