public async Task <Object> Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest("invalid id"));
            }
            var recored = authDb.DateSheetInitial.Where(a => a.ID == id).FirstOrDefault();

            if (recored != null)
            {
                authDb.Remove(recored);
                await authDb.SaveChangesAsync();

                return(Ok("deleted successfully"));
            }
            return(BadRequest("no recored found"));
        }
        public async Task <object> Delete(int?id)
        {
            if (id != 0)
            {
                var student = await authDb.Students.FindAsync(id);

                if (student != null)
                {
                    authDb.Remove(student);
                    await authDb.SaveChangesAsync();

                    return(Ok("Deleted successfully"));
                }
                else
                {
                    BadRequest("No recored found");
                }
            }
            return(BadRequest("invalid id"));
        }
Esempio n. 3
0
        public async Task <Object> Delete(int id = 0)
        {
            if (id != 0)
            {
                Course course = await Task.Run(() => authDb.Courses.Where(a => a.ID == id).FirstOrDefault());

                if (course != null)
                {
                    await Task.Run(() => authDb.Remove(course));

                    await authDb.SaveChangesAsync();

                    return(Ok("deleted successfully"));
                }
                else
                {
                    return(BadRequest("data not found"));
                }
            }
            return(BadRequest("invalid id"));
        }