Esempio n. 1
0
 public Time GetById(int id)
 {
     if (id > 0)
     {
         return(_timeRepository.GetById(id));
     }
     return(null);
 }
Esempio n. 2
0
        public bool ValidationWithDetails(Course entity, int LanguageId, int TimeId, int BranchId, bool IdValidation)
        {
            bool isValid = true;

            if (IdValidation == true)
            {
                if (entity.CourseId == 0 || _courseRepository.GetById(entity.CourseId) == null)
                {
                    ErrorMessage += "CourseId is Invalid."; isValid = false;
                }
            }
            if (string.IsNullOrEmpty(entity.Name))
            {
                ErrorMessage += "Name is Invalid."; isValid = false;
            }
            if (string.IsNullOrEmpty(entity.Url))
            {
                ErrorMessage += "Url is Invalid."; isValid = false;
            }
            if (string.IsNullOrEmpty(entity.Description))
            {
                ErrorMessage += "Description is Invalid."; isValid = false;
            }
            if (string.IsNullOrEmpty(entity.Level))
            {
                ErrorMessage += "Level is Invalid."; isValid = false;
            }
            if (string.IsNullOrEmpty(entity.StartDate))
            {
                ErrorMessage += "StartDate is Invalid."; isValid = false;
            }
            if (string.IsNullOrEmpty(entity.EndDate))
            {
                ErrorMessage += "EndDate is Invalid."; isValid = false;
            }
            if ((LanguageId != 0 && _languageRepository.GetById(LanguageId) == null) || LanguageId == 0)
            {
                ErrorMessage += "LanguageId Is Invalid"; isValid = false;
            }
            if ((TimeId != 0 && _timeRepository.GetById(TimeId) == null) || TimeId == 0)
            {
                ErrorMessage += "TimeId Is Invalid"; isValid = false;
            }
            if ((BranchId != 0 && _branchRepository.GetById(BranchId) == null) || BranchId == 0)
            {
                ErrorMessage += "BranchId Is Invalid"; isValid = false;
            }
            System.Console.WriteLine(isValid);
            System.Console.WriteLine(ErrorMessage);
            return(isValid);
        }