示例#1
0
 /// <summary>
 /// Creates a Criminal
 /// </summary>
 /// <param name="CriminalEntity"></param>
 /// <returns></returns>
 public long CreateCriminal(CriminalEntity CriminalEntity)
 {
     using (var scope = new TransactionScope())
     {
         var Criminal = new Criminal
         {
             FName = CriminalEntity.FName,
             LName = CriminalEntity.LName,
             Age = CriminalEntity.Age,
             Height = CriminalEntity.Height,
             Weight = CriminalEntity.Weight,
             Nationality = CriminalEntity.Nationality,
             Sex = CriminalEntity.Sex
         };
         _unitOfWork.CriminalRepository.Insert(Criminal);
         _unitOfWork.Save();
         scope.Complete();
         return Criminal.Id;
     }
 }
示例#2
0
 private void CreateCriminalPDF(CriminalEntity criminal)
 {
     string content = GetDefaultData();
     string criminalData = GetCriminalData(criminal, content);
     CreateCriminalPDF(criminalData, criminal.FName);
 }
示例#3
0
 private string GetCriminalData(CriminalEntity entity, string content)
 {
     return content.Replace("{{Criminal_Name}}", entity.FName + entity.LName)
         .Replace("{{Criminal_Age}}", entity.Age != null ? entity.Age.ToString() : "Not Available")
         .Replace("{{Criminal_Sex}}", !string.IsNullOrEmpty(entity.Sex) ? entity.Sex : "Not Available")
         .Replace("{{Criminal_Height}}", entity.Height != null ? entity.Height.ToString() : "Not Available")
         .Replace("{{Criminal_Weight}}", entity.Weight != null ? entity.Weight.ToString() : "Not Available")
         .Replace("{{Criminal_Nationality}}", !string.IsNullOrEmpty(entity.Nationality) ? entity.Nationality : "Not Available");
 }
示例#4
0
 /// <summary>
 /// Updates a Criminal
 /// </summary>
 /// <param name="CriminalId"></param>
 /// <param name="CriminalEntity"></param>
 /// <returns></returns>
 public bool UpdateCriminal(int CriminalId, CriminalEntity CriminalEntity)
 {
     var success = false;
     if (CriminalEntity != null)
     {
         using (var scope = new TransactionScope())
         {
             var Criminal = _unitOfWork.CriminalRepository.GetByID(CriminalId);
             if (Criminal != null)
             {
                 Criminal.FName = CriminalEntity.FName;
                 Criminal.LName = CriminalEntity.LName;
                 Criminal.Age = CriminalEntity.Age;
                 Criminal.Height = CriminalEntity.Height;
                 Criminal.Weight = CriminalEntity.Weight;
                 Criminal.Nationality = CriminalEntity.Nationality;
                 Criminal.Sex = CriminalEntity.Sex;
                 _unitOfWork.CriminalRepository.Update(Criminal);
                 _unitOfWork.Save();
                 scope.Complete();
                 success = true;
             }
         }
     }
     return success;
 }