示例#1
0
        public async Task <IActionResult> Delete(string studno, int subid)
        {
            try
            {
                var subject = await _repo.GetSubByStudno(studno, subid);

                if (subject == null)
                {
                    return(NotFound("Failed to find the subject to delete"));
                }
                _repo.Delete(subject);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("Failed to delete talk"));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to get Talks"));
            }
        }
示例#2
0
        public async Task <IActionResult> Delete(string studno)
        {
            try
            {
                var oldStud = await _repo.GetStudentsRec(studno);

                if (oldStud == null)
                {
                    return(NotFound());
                }

                _repo.Delete(oldStud);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure -DELETE"));
            }

            return(BadRequest("Failed to delete the camp"));
        }
        public DeleteStudent DeleteStudent(DeleteStudent obj)
        {
            var returnModel           = new DeleteStudent();
            var Student               = _studentsRepo.Get(obj.StudentId);
            var studentsList          = _studentsRepo.GetAll().ToList();
            var StudentPromotionsList = _StudentPromotionsRepo.GetAll().ToList();
            var query = (from p in StudentPromotionsList
                         where p.StudentId == obj.StudentId
                         select p);

            foreach (var item in query)
            {
                var StudentPromotion = _StudentPromotionsRepo.Get(item.Id);
                if (StudentPromotion != null)
                {
                    _StudentPromotionsRepo.Delete(StudentPromotion);
                    returnModel.Message = "Delete Successful.";
                }
            }
            if (Student != null)
            {
                _studentsRepo.Delete(Student);
                if (Student.IP300X200 != null)
                {
                    string DelImgofIP300X200 = Path.Combine(obj.WebRootPath, Student.IP300X200);
                    _commonServ.DelFileFromLocation(DelImgofIP300X200);
                }
                returnModel.Message = "Delete Successful.";
            }
            return(returnModel);
        }