コード例 #1
0
 public void SavePosition()
 {
     try
     {
         if (Position.PositionId == 0)
         {
             if (Position.Description == null)
             {
                 Position.Description = "";
             }
             bool uniquePositionName = service.CheckPositionName(Position.Name);
             if (!uniquePositionName)
             {
                 MessageBoxResult result = MessageBox.Show("Are you sure you want to save the new position", "Add New Position", MessageBoxButton.YesNo);
                 if (result == MessageBoxResult.Yes)
                 {
                     int positionId = service.AddPosition(Position);
                     if (positionId != 0)
                     {
                         MessageBox.Show("You have successfully added new position");
                         Logging.LoggAction("AddNewPositionViewModel", "Info", "Succesfull add new position");
                         addNewPosition.Close();
                     }
                 }
                 else
                 {
                     addNewPosition.Close();
                 }
             }
             else
             {
                 MessageBox.Show("Name is not unique!");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }