public static int SAVE(int personId, EmailAddress emailToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (personId <= 0)
                saveBrokenRules.Add("Person", "Invalid ID.");

            //make sure Email is in the correct format
            ValidateEmail(emailToSave, ref saveBrokenRules);

            //email type is required
            if(emailToSave.EmailType.EntityTypeId <=0)
            {
                saveBrokenRules.Add("Email Address Type", "Type is Required.");
            }

            //check for validation errors
            if(saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving Email.", saveBrokenRules);
            }
            else 
            {
                //validation success - call DAL to save
                return EmailAddressDAL.Save(personId, emailToSave);
            }
        }
        private static bool ValidateDrawingDate(DrawingDateBO drawingDateToValidate, ref BrokenRuleCollection brokenRules)
        {
            //Set default return value to true
            bool returnValue = true;

            //Validate email address
            if (drawingDateToValidate != null)
            {
                if (drawingDateToValidate.DrawingDate == DateTime.MinValue)
                {
                    //Email was not in a valid format
                    brokenRules.Add("Drawing Date", "is an invalid email format.");
                    returnValue = false;
                }
                if (drawingDateToValidate.DrawingDate > DateTime.Now)
                {
                    //Email cannot be a date beyond the current date
                    brokenRules.Add("Drawing Date " + drawingDateToValidate.DrawingDate.ToString(), "cannot be a future date.");

                }
                if(drawingDateToValidate.DrawingDate == DateTime.MinValue)
                {
                    //Emailis required
                    brokenRules.Add("Drawing Date", "Drawing date is required");
                    returnValue = false;
                }
            }
            else
            {
                //Generic error - class not instantiated
                brokenRules.Add("Drawing Date", "Drawing Date was not instantiated.");
                returnValue = false;
            }
            return returnValue;
        }
        public static int Save(int employeeId, EmailAddress emailToSave)
        {
            //Instantiate a brokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (employeeId <= 0)
            {
                saveBrokenRules.Add("Employee", "Invalid Id");
            }

            //Make sure email is in correct format
            ValidateEmail(emailToSave, ref saveBrokenRules);

            //email Type is required
            if (emailToSave.EntityType.EntityTypeId <= 0)
            {
                saveBrokenRules.Add("Email Address Type", "Type is required.");
            }

            //Check for validation errors
            if (emailToSave.EntityType.EntityTypeId <= 0)
            {
                throw new BLLException("There was an error saving email.", saveBrokenRules);
            }
            else
            {
                //Validation a success - call the data access layer to save
                return EmailAddressDAL.Save(employeeId, emailToSave);
            }
        }
Example #4
0
        public static int SaveDrawing(int lotteryDrawingId, LotteryDrawing drawingToSave)
        {
            //notes:    instantiate BrokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (lotteryDrawingId <= 0)
                saveBrokenRules.Add("Drawing", "Drawing must be associated with a valid Drawing");

            if (drawingToSave == null)
                saveBrokenRules.Add("Drawing", "Invalid Drawing object.");

            else
            {
                if (string.IsNullOrEmpty(drawingToSave.PrizeAmount))
                    saveBrokenRules.Add("PrizeAmount", "Value is required");
            }

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                drawingToSave.PrizeAmount = new LotteryDrawing { LotteryDrawingId = lotteryDrawingId };
                return LotteryDrawingDAL.Save(drawingToSave);
            }
        }
        public static int SaveMake(VehicleMake vehicleMaketoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (vehicleMaketoSave == null)
                saveBrokenRules.Add("Vehicle Make", "Invalid vehicleMake object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleMaketoSave.VehicleMakeName))
                    saveBrokenRules.Add("Vehicle Make Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                //check to make sure name dosent exist
                VehicleMake tempMake = GetMake(vehicleMaketoSave.VehicleMakeName);
                if (tempMake == null)
                    return VehicleMakeDAL.Save(vehicleMaketoSave);
                else
                    return
                        tempMake.VehicleMakeId;
            }

        }
        private static bool ValidateEmail(EmailAddress emailToValidate, ref BrokenRuleCollection brokenRules)
        {
            //set default return value to true
            bool returnValue = true;

            //Validate email address
            if (emailToValidate != null)
            {
                if (!string.IsNullOrEmpty(emailToValidate.EmailAddressName))
                {
                    if (!EmailValidator.IsValid(emailToValidate.EmailAddressName.Trim()))
                    {
                        //email was not in a valid format
                        brokenRules.Add("Email Address", emailToValidate.EmailAddressName.Trim() + " is an invalid email format.");
                        returnValue = false;
                    }
                }
                else
                {
                    //email is required
                    brokenRules.Add("Email Address", "Email is Required.");
                    returnValue = false;
                }
            }
            else
            {
                brokenRules.Add("Email Address", "Email class was not instantiated");
                returnValue = false;
            }
            return returnValue;
        }
Example #7
0
 public static void IsClientIdValid(long value, BrokenRuleCollection brokenRules)
 {
     if (value == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Client Id";
         item.Severity = "Critical";
         item.Description = "Please select a Client.";
         brokenRules.Add(item);
     }
 }
Example #8
0
 public static void IsBirthdateValid(Nullable<DateTime> value, BrokenRuleCollection brokenRules)
 {
     if (value.HasValue == false)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Birthdate";
         item.Severity = "Critical";
         item.Description = "Please enter a birthdate.";
         brokenRules.Add(item);
     }
 }
Example #9
0
 public static void AreCodesSet(YellowstonePathology.Business.Billing.Model.CptBillingCodeItemCollection cptBillingCodes, BrokenRuleCollection brokenRules)
 {
     if (cptBillingCodes.Count == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Codes Not Set";
         item.Severity = "Critical";
         item.Description = "Please Set Codes.";
         brokenRules.Add(item);
     }
 }
Example #10
0
 public static void IsPatientIdValid(string value, BrokenRuleCollection brokenRules)
 {
     if (value == "0" || value == string.Empty)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Patient Id";
         item.Severity = "Critical";
         item.Description = "Please select a link this case.";
         brokenRules.Add(item);
     }
 }
Example #11
0
 public static void IsDistributionValid(YellowstonePathology.Business.ReportDistribution.Model.TestOrderReportDistributionCollection testOrderReportDistributionCollection, BrokenRuleCollection brokenRules)
 {
     if (testOrderReportDistributionCollection.Count == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Report Distribution not set.";
         item.Severity = "Critical";
         item.Description = "Please set the report distribution.";
         brokenRules.Add(item);
     }
 }
Example #12
0
 public static void IsPhyscianIdValid(int value, BrokenRuleCollection brokenRules)
 {
     if (value == 0)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Blank Physician Id";
         item.Severity = "Critical";
         item.Description = "Please select a Physician.";
         brokenRules.Add(item);
     }
 }
Example #13
0
 public static void IsDateValid(string value, BrokenRuleCollection brokenRules)
 {
     DateTime result;
     if (DateTime.TryParse(value, out result) == false)
     {
         Validation.BrokenRuleItem item = new BrokenRuleItem();
         item.RuleName = "Date Not Valid";
         item.Severity = "Critical";
         item.Description = "Please enter a valid date.";
         brokenRules.Add(item);
     }
 }
Example #14
0
        public static Entity GetItem(string entityName)
        {
            BrokenRuleCollection getBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(entityName))
            {
                getBrokenRules.Add("Entity Name", "Name is missing.");
                throw new BLLException("There was and error retriving Entity item.", getBrokenRules);
            }
            else
                return EntityDAL.GetItem(entityName);

        }
        public static EntityType GetItem(int EntityTypeId)
        {
            BrokenRuleCollection getBrokenRules = new BrokenRuleCollection();

            if (EntityTypeId < 0)
            {
                getBrokenRules.Add("Entity Type", "EntityType is missing.");
                throw new BLLException("There was and error retriving EntityType item.", getBrokenRules);
            }
            else
                return EntityTypeDAL.GetItem(EntityTypeId);

        }
        public static int Save(string entityName, string entityTypeValue)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(entityName))
                saveBrokenRules.Add("Entity", "Invalid Entity Name.");

            if (string.IsNullOrEmpty(entityTypeValue))
                saveBrokenRules.Add("Entity Type", "Value is required");

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                Entity tempEntity = EntityManager.GetItem(entityName);
                return EntityTypeDAL.Save(tempEntity.EntityId, new EntityType(entityTypeValue));
            }
        }
        public static int Save(int entityId, EntityType entityTypeToSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (entityId <= 0)
                saveBrokenRules.Add("Entity", "Invalid Entity Id.");

            if (entityTypeToSave == null)
                saveBrokenRules.Add("Entity Type", "Invalid EntityType object.");
            else
            {
                if (string.IsNullOrEmpty(entityTypeToSave.EntityTypeValue))
                    saveBrokenRules.Add("Entity Type", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules Failed", saveBrokenRules);
            else
                return EntityTypeDAL.Save(entityId, entityTypeToSave);
        }
Example #18
0
        public static int SaveGame(int lotteryId, LotteryGameValue gameToSave)
        {
            //notes:    instantiate BrokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (lotteryId <= 0)
                saveBrokenRules.Add("Lottery", "Invalid Lottery Game Id");

            if (gameToSave == null)
                saveBrokenRules.Add("Game Name", "Invalid GameName objects.");

            else
            {
                if (string.IsNullOrEmpty(gameToSave.GameName))
                    saveBrokenRules.Add("Game Name", "Game Name is required");
            }

            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
                return LotteryGameDAL.Save2(lotteryId, gameToSave);
        }
        public static int Save(int drawingDateId, int gameId, DrawingDateBO drawingDateToSave)
        {
            //Instantiates a brokenRules collection and check for any validation errors
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (gameId <= 0)
            {
                saveBrokenRules.Add("Drawing date", "Invalid game id");
            }

            ValidateDrawingDate(drawingDateToSave, ref saveBrokenRules);

            if (saveBrokenRules.Count() > 0)
            {
                throw new BLLException("There was an error saving email.", saveBrokenRules);
            }
            else
            {
                //Call DAL to save
                return DrawingDateDAL.Save(drawingDateId, gameId, drawingDateToSave);
            }
        }
        public static int SaveModel(int vehicleMakeId, VehicleModel vehicleModeltoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (vehicleMakeId<=0)
                saveBrokenRules.Add("Vehicle Make Id", "Vehicle Model must be associated with a valid VehicleMake Id .");

            if (vehicleModeltoSave == null)
                saveBrokenRules.Add("Vehicle Model", "Invalid VehicleModel Object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleModeltoSave.VehicleModelName))
                    saveBrokenRules.Add("Vehicle Model Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                vehicleModeltoSave.Make = new VehicleMake { VehicleMakeId = vehicleMakeId };
                return VehicleModelDAL.Save(vehicleModeltoSave);
            }

        }
Example #21
0
        public void Validate(Patient.Model.Patient patient, BrokenRuleCollection brokenRules)
        {
            if (patient.PatientId == "0" | patient.PatientId == string.Empty)
            {
                Validation.BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "Patient Not Linked.";
                brokenRule.Description = "Please link this patient.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }

            if (patient.LastName == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient Last Name";
                brokenRule.Description = "Please enter the patients last name.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
            if (patient.FirstName == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient First Name";
                brokenRule.Description = "Please enter the patients first name.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
            if (patient.Birthdate.ToString() == string.Empty)
            {
                BrokenRuleItem brokenRule = new BrokenRuleItem();
                brokenRule.RuleName = "No Patient Birthdate";
                brokenRule.Description = "Please enter the patients birthdate.";
                brokenRule.Severity = "Critical";
                brokenRules.Add(brokenRule);
            }
        }
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //validate our form controls
            //required feilds
            if (string.IsNullOrEmpty(FirstName.Text.Trim()))
                brokenRules.Add("First Name", "Required feild.");

            if (string.IsNullOrEmpty(LastName.Text.Trim()))
                brokenRules.Add("Last Name", "Required feild.");

            //Valid Dates if user entered in data
            if (!string.IsNullOrEmpty(BirthDate.Text.Trim()))
            {
                if (BirthDate.Text.Trim().ToDate() == DateTime.MinValue)//trim?
                    brokenRules.Add("Date of Birth", "Please enter a valid date.");

            }
            if (!string.IsNullOrEmpty(HireDate.Text.Trim()))
            {
                if (HireDate.Text.Trim().ToDate() == DateTime.MinValue)
                    brokenRules.Add("Date of Hire", "Please enter a valid date.");

            }
            if (!string.IsNullOrEmpty(TermDate.Text.Trim()))
            {
                if (TermDate.Text.Trim().ToDate() == DateTime.MinValue)
                    brokenRules.Add("Date of Termination", "Please enter a valid date.");

            }

            //check if broken rulles collection has any items
            if (brokenRules.Count() > 0)
            {
                CustomMessageArea.BrokenRules = brokenRules;

                //execute display() method to render to screen
                CustomMessageArea.Display();

                if (brokenRules.Count() == 1)
                {
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again.");
                }
                else
                {
                    this.DisplayLocalMessage("There were Some errors processing your form. Please correct and try saving again.");
                }
                returnValue = false;
            }
            return returnValue;
        }
        public static int SaveModel(string vehicleMakeName, VehicleModel vehicleModeltoSave)
        {
            BrokenRuleCollection saveBrokenRules = new BrokenRuleCollection();

            if (string.IsNullOrEmpty(vehicleMakeName))
                saveBrokenRules.Add("Vehicle Make Name", "Vehicle Model must be associated with a valid Vehicle Make Name.");

            if (vehicleModeltoSave == null)
                saveBrokenRules.Add("Vehicle Model", "Invaild VehicleModel object.");
            else
            {
                if (string.IsNullOrEmpty(vehicleModeltoSave.VehicleModelName))
                    saveBrokenRules.Add("Vehicle Make Name", "Value is Required.");
            }
            if (saveBrokenRules.Count() > 0)
                throw new BLLException("Validation rules failed.", saveBrokenRules);
            else
            {
                //check to make sure name dosent exist
                VehicleMake itemMake = GetMake(vehicleMakeName);
                if (itemMake == null)
                {
                    itemMake = new VehicleMake();
                    itemMake.VehicleMakeId = SaveMake(new VehicleMake{VehicleMakeName = vehicleMakeName});
                }
               
                vehicleModeltoSave.Make = itemMake;
                return VehicleModelDAL.Save(vehicleModeltoSave);
               
            }

        }
        private bool ValidateForm()
        {
            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtFirstName.Text.Trim()))
            {
                brokenRules.Add("First Name", "Required Field");
            }
            if (string.IsNullOrEmpty(txtLastName.Text.Trim()))
            {
                brokenRules.Add("Last Name", "Required Field");
            }

            //Validate dates if user entered in data
            if (string.IsNullOrEmpty(txtBirthDate.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtBirthDate.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Birth", "Please enter a valid date.");
                }
            }
            if (string.IsNullOrEmpty(txtDateOfHire.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtDateOfHire.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Hire", "Please enter a valid date.");
                }
            }
            if (string.IsNullOrEmpty(txtDateOfTermination.Text.Trim()))
            {
                if (txtBirthDate.Text == "" || Convert.ToDateTime(txtDateOfTermination.Text.Trim()) == DateTime.MinValue)
                {
                    brokenRules.Add("Date of Termination", "Please enter a valid date.");
                }
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
 public BLLException(string message, Exception inner, BrokenRuleCollection brokenRules)
     :base(message,inner)
 {
     this.BrokenRules = brokenRules;
 }
        private bool ValidateForm()
        {
            PageMessageArea.Visible = true;

            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtMatch.Text.Trim()))
            {
                brokenRules.Add("Match", "Required Field");
            }
            if (string.IsNullOrEmpty(txtWin.Text.Trim()))
            {
                brokenRules.Add("Win", "Required Field");
            }
            if (string.IsNullOrEmpty(txtOdds.Text.Trim()))
            {
                brokenRules.Add("Odds", "Required Field");
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
 public void Validate(object value, BrokenRuleCollection rules)
 {
     this.m_ValidationRuleHandler(value, rules);
 }
        private bool ValidateForm()
        {
            PageMessageArea.Visible = true;

            //Create bool for our return value and instantiate a new brokenRuleCollection object
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            //Validate our form controls required fields
            if (string.IsNullOrEmpty(txtMovieTitle.Text.Trim()))
            {
                brokenRules.Add("Movie Title", "Required Field");
            }
            if (string.IsNullOrEmpty(txtYearReleased.Text.Trim()))
            {
                brokenRules.Add("Year Released", "Required Field");
            }

            //Validate integer inputs and if user entered correct integers format and if integer is greater than zero
            int value;
            if (int.TryParse(txtYearReleased.Text, out value))
            {
                if (value <= 0)
                {
                    brokenRules.Add("Year Released", "Please enter a valid integer greater than zero.");
                }
            }
            else
            {
                brokenRules.Add("Year Released", "Only numeric values allowed.");
            }

            //Check if broken rules collection has any items
            if (brokenRules.Count() > 0)
            {
                //Bind the collection to the list control
                MessageList.DataSource = brokenRules;
                MessageList.DataBind();

                //Check to see if there were mutliple errors - display appropriate message
                if (brokenRules.Count() == 1)
                {
                    //Display main error message to user
                    this.DisplayLocalMessage("There was an error processing your form. Please correct and try saving again");
                }
                else
                {
                    this.DisplayLocalMessage("There was some errors processing your form. Please correct and try saving again");
                }
                returnValue = false;
            }
            return returnValue;
        }
Example #29
0
        private void DisplayLocalMessage(string message, BrokenRuleCollection brokenRules)
        {
            CustomMessageArea.Visible = true;
            CustomMessageArea.Message = message;

            if (brokenRules.Count() > 0)
                CustomMessageArea.BrokenRules = brokenRules;

            //notes:    execute Display() method to render to screen
            CustomMessageArea.Display();
        }
Example #30
0
        private bool ValidateForm()
        {
            bool returnValue = true;
            BrokenRuleCollection brokenRules = new BrokenRuleCollection();

            if (GameList.SelectedValue.Trim().ToInt() == 0)
            {
                brokenRules.Add("Lottery Game", "Please select a valid Lottery Game from the drop-down list.");
                returnValue = false;
            }

            if(string.IsNullOrEmpty(GameValueField.Text.Trim()))
            {
                brokenRules.Add("Lookup Value", "Required field.");
                    returnValue = false;
            }

            if (!returnValue)
            {
                if(brokenRules.Count() == 1)
                    this.DisplayLocalMessage("There is an error with your submission. Please correct and try again.", brokenRules);
                else
                    this.DisplayLocalMessage("There were some errors with your submission. Please correct and try again.", brokenRules);
            }

            return returnValue;
        }