示例#1
0
 public JsonResult GetStudentList()
 {
     using (MusicStoreDataContext dbContext = new MusicStoreDataContext())
     {
         List <Student> studentList = dbContext.Student.ToList();
         var            x           = Json(studentList, JsonRequestBehavior.AllowGet);
         return(x);
     }
 }
示例#2
0
 public JsonResult AddStudent(Student student)
 {
     if (student != null)
     {
         using (MusicStoreDataContext dbContext = new MusicStoreDataContext())
         {
             dbContext.Student.Add(student);
             dbContext.SaveChanges();
             return(Json(student, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json("Some Error Occured"));
     }
 }
示例#3
0
 public string DeleteStudent(int Id)
 {
     if (Id != 0)
     {
         using (MusicStoreDataContext dataContext = new MusicStoreDataContext())
         {
             // int id = Convert.ToInt32(Id);
             var lstStud = dataContext.Student.Where(x => x.ID == Id).FirstOrDefault();
             dataContext.Student.Remove(lstStud);
             dataContext.SaveChanges();
             return("Student has been deleted succhessfully.");
         }
     }
     else
     {
         return(" Oops! Error occered.");
     }
 }
示例#4
0
 public string UpdateStudent(Student stu)
 {
     if (stu != null)
     {
         using (MusicStoreDataContext dbContext = new MusicStoreDataContext())
         {
             Student lstStudent = dbContext.Student.Where(x => x.ID == stu.ID).FirstOrDefault();
             lstStudent.StudentName    = stu.StudentName;
             lstStudent.StudentAddress = stu.StudentAddress;
             lstStudent.StudentEmail   = stu.StudentEmail;
             dbContext.SaveChanges();
             return("Student Updated");
         }
     }
     else
     {
         return("Oops! something went wrong.");
     }
 }
示例#5
0
 public Repository(MusicStoreDataContext context)
 {
     this.context = context;
 }
示例#6
0
 public Repository()
 {
     context = new MusicStoreDataContext();
     DbSet   = context.Set <T>();
 }
示例#7
0
 public Repositery(MusicStoreDataContext context)
 {
     _context = context;
 }
示例#8
0
 public AddToCartCmd(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
 public DropListServiceQry(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#10
0
 public CartQuery(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#11
0
 public AlbumCmd(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#12
0
 public StoreQry(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#13
0
 public UserValidateQry(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#14
0
 public SubmitOrderCmd(MusicStoreDataContext dbContext, ICartService cartService)
 {
     _dbContext   = dbContext;
     _cartService = cartService;
 }
示例#15
0
 public RegisterUserCmd(MusicStoreDataContext dbContext)
 {
     _dbContext = dbContext;
 }