コード例 #1
0
ファイル: TubeService.svc.cs プロジェクト: abonSerg/Clinic
 public string EditTube(DtoTube dtoTube)
 {
     var uniqeTube = TubeMethods.Instance.GetTubeByCode(dtoTube.Code);
     if (!dtoTube.IsEdit)
     {
         var tube = new Tube()
         {
             Code = dtoTube.Code,
             Name = dtoTube.Name,
             Volume = dtoTube.Volume
         };
         return TubeMethods.Instance.InsertTube(tube);
     }
     else
     {
         var tube = new Tube()
         {
             Id = TubeMethods.Instance.GetTubeByCode(dtoTube.Code).Id,
             Code = dtoTube.Code,
             Name = dtoTube.Name,
             Volume = dtoTube.Volume
         };
         return TubeMethods.Instance.UpdateTube(tube);
     }
 }
コード例 #2
0
 public static void ValidateTube(Tube tube)
 {
     if (string.IsNullOrEmpty(tube.Code) || string.IsNullOrEmpty(tube.Name))
     {
         throw new TubeMandatoryFieldsException();
     }
     else
     {
         if (tube.Volume > 1000)
         {
             throw new TubeVolumeException();
         }
     }
 }
コード例 #3
0
ファイル: TubeMethods.cs プロジェクト: abonSerg/Clinic
 public static void ValidateTube(Tube tube)
 {
     if (string.IsNullOrEmpty(tube.Code) || string.IsNullOrEmpty(tube.Name))
     {
         throw new TubeMandatoryFieldsException();
     }
     else
     {
         if (tube.Volume > 1000)
         {
             throw new TubeVolumeException();
         }
     }
 }
コード例 #4
0
 public string UpdateTube(Tube tube)
 {
     try
     {
         ValidateTube(tube);
         UpdateTubeEntity <Tube>(tube);
         string message = string.Format("Tube {0} updated", tube.Code);
         log.Info(message);
         return("c");
     }
     catch (TubeException e)
     {
         log.Error(string.Format("Error saving Tube with Code = {0}, ErrorMessage: {1}", tube.Code, e.Message));
         return(e.Message);
     }
     catch (GenericADOException e)
     {
         log.Error(string.Format("Error saving Tube with Code = {0}, ErrorMessage: not UNIQUE Code {0}/{1}", tube.Code, e.Message));
         return("Code will be UNIQUE!");
     }
 }
コード例 #5
0
ファイル: TubeMethods.cs プロジェクト: abonSerg/Clinic
 public string InsertTube(Tube tube)
 {
     try
     {
         ValidateTube(tube);
         InsertTubeEntity<Tube>(tube);
         string message = string.Format("Tube {0} saved", tube.Code);
         log.Info(message);
         return "s";
     }
     catch (TubeException e)
     {
         log.Error(string.Format ("Error saving Tube with Code = {0}, ErrorMessage: {1}",tube.Code,e.Message));
         return e.Message;
     }
     catch (GenericADOException e)
     {
         log.Error(string.Format("Error saving Tube with Code = {0}, ErrorMessage: not UNIQUE Code {0}/{1}", tube.Code, e.Message));
         return "Code will be UNIQUE!";
     }
 }
コード例 #6
0
ファイル: TubeMethodsTests.cs プロジェクト: abonSerg/Clinic
        public void ValidateTube_VolumeException()
        {
            var tube = new Tube()
            {
                Code = "code",
                Name = "name",
                Volume = 1001

            };
            bool isExceptionExist = false;
            try
            {
                TubeMethods.ValidateTube(tube);
            }
            catch (Exception)
            {
                isExceptionExist = true;
            }

            Assert.IsTrue(isExceptionExist);
              ;
        }