Ejemplo n.º 1
0
 public bool SaveType(EditTypeModel model)
 {
     try
     {
         if (!ValidateModel(model))
             return false;
         var type = new EmployeeDocumentType();
         if (model.Id > 0)
             type = EmployeeDocumentTypeDao.Load(model.Id);
         type.Name = model.Name.Trim();
         EmployeeDocumentTypeDao.MergeAndFlush(type);
         return true;
     }
     catch (Exception ex)
     {
         Log.Error("Exception", ex);
         model.Error = "Исключение: " + ex.GetBaseException().Message;
         return false;
     }
 }
Ejemplo n.º 2
0
 public void GetEditTypeModel(EditTypeModel model)
 {
     if (model.Id <= 0)
         return;
     EmployeeDocumentType type = EmployeeDocumentTypeDao.Load(model.Id);
     model.Name = type.Name;
 }
Ejemplo n.º 3
0
 public ContentResult SaveType(int id, string name)
 {
     bool saveResult;
     string error;
     try
     {
         var model = new EditTypeModel { Id = id, Name = name};
         saveResult = AdminBl.SaveType(model);
         error = model.Error;
     }
     catch (Exception ex)
     {
         Log.Error("Exception on SaveType:", ex);
         error = ex.GetBaseException().Message;
         saveResult = false;
     }
     JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
     var jsonString = jsonSerializer.Serialize(new SaveTypeResult { Error = error, Result = saveResult });
     return Content(jsonString);
 }
Ejemplo n.º 4
0
 protected bool ValidateModel(EditTypeModel model)
 {
     if (string.IsNullOrEmpty(model.Name) || string.IsNullOrEmpty(model.Name.Trim()))
     {
         model.Error = "Название - обязательное поле.";
         return false;
     }
     if (EmployeeDocumentTypeDao.IsTypeWithNameAndOtherIdExists(model.Name.Trim(), model.Id))
     {
         model.Error = "Название типа заявки должно быть уникальным.";
         return false;
     }
     return true;
 }
Ejemplo n.º 5
0
 public ActionResult EditTypeDialog(int Id)
 {
     try
     {
         EditTypeModel model = new EditTypeModel { Id = Id };
         AdminBl.GetEditTypeModel(model);
         return PartialView(model);
     }
     catch (Exception ex)
     {
         Log.Error("Exception",ex);
         string error = "Ошибка при загрузке данных: " + ex.GetBaseException().Message;
         return PartialView("DialogError", new DialogErrorModel {Error = error});
     }
 }