Esempio n. 1
0
 /// <summary>
 /// 删除一个学校单位
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="id">一学校单位的主键</param>
 /// <returns></returns>
 public bool Delete(ref ValidationErrors validationErrors, string id)
 {
     try
     {
         return(repository.Delete(id) == 1);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Esempio n. 2
0
        public async Task <JsonResult> Delete(string ids)
        {
            ErrorCodes result;
            string     html = "";

            try
            {
                result = SchoolRepository.Delete(ids, GetLogedinUser());
            }
            catch (ENovateException eex)
            {
                Log.Logger.Error(eex, "Failed to delete the school.");
                result = eex.ErrorCode;
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Failed to delete the shool.");
                result = ErrorCodes.SaveFailure;
            }
            if (result == ErrorCodes.None)
            {
                List <MSchool> schools = SchoolRepository.GetAll();
                html = await ViewRenderService.RenderViewToStringAsync("~/Areas/Admin/Views/School/_List.cshtml", schools);
            }
            string msg = (result == ErrorCodes.None) ? StringLocalizer["I.HSP-M002.0005"].Value
                                                     : StringLocalizer[result.GetResourceKey()].Value;

            return(Json(new { status = (result == ErrorCodes.None) ? Result.Success : Result.Failure, message = msg, html }));
        }
        public ActionResult DeleteConfirmed(int Id)
        {
            var school = schoolRepository.GetById(Id);

            schoolRepository.Delete(Id);
            schoolRepository.Save();
            return(RedirectToAction("Index"));
        }
        public void Delete_Normal_Conditions()
        {
            var repo   = new SchoolRepository();
            var school = new School("East High School");
            var count  = repo.GetAll().Count();

            repo.Add(school);
            repo.Delete(school);
            Assert.True(count == repo.GetAll().Count());
        }