예제 #1
0
파일: AdminBl.cs 프로젝트: andreyu/Reports
 public bool DeleteEmployees(DeleteEmployeesModel model)
 {
     try
     {
         int deletedEmployees = UserDao.DeleteEmployees(model.Date);
         Log.DebugFormat("Удалено {0} сотрудников (дата {1})", deletedEmployees, model.Date.ToShortDateString());
     }
     catch (Exception ex)
     {
         Log.Error("Exception", ex);
         model.Error = string.Format("Исключение {0} ", ex.GetBaseException().Message);
         return false;
     }
     return true;
 }
예제 #2
0
 public ContentResult DeleteEmployees(string date)
 {
     bool saveResult = false;
     string error;
     try
     {
         CheckUserRole(false);
         DateTime deleteDate;
         if (!DateTime.TryParse(date, out deleteDate))
             error = "Неправильная дата";
         else if (deleteDate >= DateTime.Today)
             error = "Дата должна быть в прошлом.";
         else
         {
             var model = new DeleteEmployeesModel { Date = deleteDate};
             saveResult = AdminBl.DeleteEmployees(model);
             error = model.Error;
         }
     }
     catch (Exception ex)
     {
         Log.Error("Exception on DeleteEmployees:", ex);
         error = ex.GetBaseException().Message;
         saveResult = false;
     }
     JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
     var jsonString = jsonSerializer.Serialize(new SaveTypeResult { Error = error, Result = saveResult });
     return Content(jsonString);
 }