Example #1
0
        public void Delete()
        {
            var school = Insert();

            _schoolRepository.Delete(school);
            _unitOfWork.SaveChanges();

            var newSchool = _schoolRepository.Table.FirstOrDefault(x => x.Id == school.Id);

            Assert.True(newSchool == null);
        }
Example #2
0
        /// <summary>
        /// ɾ��ѧУ
        /// </summary>
        /// <param name="schoolId">ѧУ����</param>
        public void Delete(long schoolId)
        {
            School school = Get(schoolId);

            EventBus <School> .Instance().OnBefore(school, new CommonEventArgs(EventOperationType.Instance().Delete()));

            schoolRepository.Delete(school);
            EventBus <School> .Instance().OnAfter(school, new CommonEventArgs(EventOperationType.Instance().Delete()));
        }
        public IActionResult Delete(int id)
        {
            _schoolRepository.Delete(id);

            var result  = _schoolRepository.Fetch();
            var results = Mapper.Map <IEnumerable <SchoolModel> >(result);

            return(new ObjectResult(results));
        }
Example #4
0
 public ActionResult Delete(School s)
 {
     try
     {
         schoolRepository.Delete(s);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete(int id)
 {
     try
     {
         _repository.Delete(id);
     }
     catch (RetryLimitExceededException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         School school = _schoolRepository.GetId(id);
         _schoolRepository.Delete(id);
         _schoolRepository.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ICommandResult Handle(DeleteSchoolCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GenericCommandResult(false, "Ops, parece que os dados da escola estão errados!", command.Notifications));
            }

            // Recupera
            var school = _repository.GetById(command.Id);

            // apaga no banco
            _repository.Delete(school);

            // Retorna o resultado
            return(new GenericCommandResult(true, "Escola apagada com sucesso!", school));
        }
Example #8
0
        public bool DeleteSchool(int id)
        {
            bool isSuccess = true;
            var  school    = schoolRepository.GetById(id);

            try
            {
                schoolRepository.Delete(school);
                SaveRecord();
                ServiceUtil <School> .WriteActionLog(id, ENUMOperation.DELETE);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in deleting School", ex);
            }
            return(isSuccess);
        }
 public IActionResult DeleteSchool(int id)
 {
     try
     {
         _schoolRepository.Delete(id);
         var Respond = Ok();
         response.StatusCode = Respond.StatusCode;
         response.Message    = Constants.Success;
         return(Ok(response));
     }
     catch (Exception)
     {
         var Respond = BadRequest();
         response.StatusCode = Respond.StatusCode;
         response.Message    = Constants.Failure;
         return(BadRequest(response));
     }
 }
Example #10
0
        public async Task <ActionResult <bool> > Delete(Guid schoolid)
        {
            var schoolx = await _schoolRepo.GetSchoolWithID(schoolid);

            if (schoolx == null)
            {
                return(BadRequest($"could not find School with id: {schoolid}"));
            }

            var noPersonels = schoolx.SchoolPersonnel.Count();

            if (noPersonels > 0)
            {
                return(BadRequest($"There are {noPersonels} personnels associated to this school"));
            }

            var noTeams = schoolx.Teams.Count();

            if (noTeams > 0)
            {
                return(BadRequest($"There are {noTeams} Teams associated to this school"));
            }

            var noSchedules = schoolx.Outreachschedules.Count();

            if (noSchedules > 0)
            {
                return(BadRequest($"There are {noSchedules} scheduless associated to this school"));
            }

            _schoolRepo.Delete(schoolx);

            var result = await _schoolRepo.SaveAll();

            return(Ok(result));
        }
Example #11
0
 // Delete
 public void DeleteSchool(School School)
 {
     SchoolRepository.Delete(School);
     SaveSchool();
 }
 public async Task Delete(int id)
 {
     await schoolRepository.Delete(id);
 }
Example #13
0
 public _ReturnProc Delete(string schoolId)
 {
     m_SchoolRepository.PersonId = this.PersonId;
     return(m_SchoolRepository.Delete(schoolId));
 }
 public IActionResult Delete(int id)
 {
     _schoolRepo.Delete(id);
     return(NoContent());
 }
Example #15
0
 public int Delete(int id)
 {
     return(schoolRepository.Delete(id));
 }
Example #16
0
 public bool Delete(string id)
 {
     return(_schoolRepository.Delete(id));
 }
Example #17
0
 public IActionResult DeleteConfirmed(int id)
 {
     _repo.Delete(id);
     return(RedirectToAction("Index"));
 }