public async Task <int> Delete(int student_id)
        {
            try
            {
                using (StudentRecordsEntities db = new StudentRecordsEntities())
                {
                    Student std = await db.Students.FindAsync(student_id);

                    if (std != null)
                    {
                        if (db.StudentFiles.Any(x => x.StudentID == std.ID))
                        {
                            db.StudentFiles.RemoveRange(db.StudentFiles.Where(x => x.StudentID == std.ID));
                        }

                        db.Students.Remove(std);

                        return(await db.SaveChangesAsync());
                    }
                    else
                    {
                        return(await Task.FromResult(0));
                    }
                }
            }
            catch (Exception)
            {
                return(await Task.FromResult(0));
            }
        }
        public async Task <int> Update(Student std)
        {
            try
            {
                using (StudentRecordsEntities db = new StudentRecordsEntities())
                {
                    Student new_std = await db.Students.FindAsync(std.ID);

                    new_std.Name        = std.Name;
                    new_std.Grade       = std.Grade;
                    new_std.DateOfBirth = std.DateOfBirth;
                    new_std.Address     = std.Address;

                    db.Entry(new_std).State = EntityState.Modified;

                    if (std.StudentFiles != null && std.StudentFiles.Count > 0)
                    {
                        foreach (var item in std.StudentFiles)
                        {
                            db.StudentFiles.Add(new StudentFile {
                                FileSize = item.FileSize, FileName = item.FileName, StudentID = std.ID
                            });
                        }
                    }

                    return(await db.SaveChangesAsync());
                }
            }
            catch (Exception)
            {
                return(await Task.FromResult(0));
            }
        }
        public async Task <int> Add(Student std)
        {
            try
            {
                using (StudentRecordsEntities db = new StudentRecordsEntities())
                {
                    db.Students.Add(std);

                    return(await db.SaveChangesAsync());
                }
            }
            catch (Exception)
            {
                return(await Task.FromResult(0));
            }
        }
        public async Task <string> DeleteFile(int file_id)
        {
            try
            {
                using (StudentRecordsEntities db = new StudentRecordsEntities())
                {
                    StudentFile file = await db.StudentFiles.FindAsync(file_id);

                    string x = file.FileName;

                    db.StudentFiles.Remove(file);

                    await db.SaveChangesAsync();

                    return(await Task.FromResult(x));
                }
            }
            catch (Exception)
            {
                return(await Task.FromResult(""));
            }
        }