Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

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