public void ShouldReturnValidWhenDeleteCommandValid()
        {
            var command = new DeleteCollegeCommand();

            command.Id = Guid.NewGuid();
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
        public void show_data(int ID)
        {
            A_Handler = new CollegeHandler();
            A1        = new College();
            A1        = A_Handler.GetCollegeDetails(ID);


            txtCollege_id.Text = A1.College_id.ToString();

            ddlReg_id.Text = A1.Reg_id.ToString();

            txtCollege_Name.Text = A1.College_Name.ToString();

            txtAddress.Text = A1.Address.ToString();

            txtCity.Text = A1.City.ToString();

            txtPhone.Text = A1.Phone.ToString();

            txtMobile.Text = A1.Mobile.ToString();

            txtFax.Text = A1.Fax.ToString();

            txtEmail.Text = A1.Email.ToString();

            txtWebsite.Text = A1.Website.ToString();

            txtCollege_code.Text = A1.College_code.ToString();

            txtPrefix.Text = A1.Prefix.ToString();

            DdlStatus.SelectedValue = A1.Status.ToString();

            btnSubmit.Text = "Update";
            btnReset.Text  = "Cancel";

            if (Request.QueryString["action"] == "del")
            {
                Label1.Text              = "Are U Sure, U want to  Delete a Record ?";
                txtCollege_id.ReadOnly   = false;
                ddlReg_id.Enabled        = false;
                txtCollege_Name.ReadOnly = false;
                txtAddress.ReadOnly      = false;
                txtCity.ReadOnly         = false;
                txtPhone.ReadOnly        = false;
                txtMobile.ReadOnly       = false;
                txtFax.ReadOnly          = false;
                txtEmail.ReadOnly        = false;
                txtWebsite.ReadOnly      = false;
                txtCollege_code.ReadOnly = false;
                txtPrefix.ReadOnly       = false;
                DdlStatus.Enabled        = false;
                btnSubmit.Text           = "Delete";
            }
        }
        public void ShouldReturnValidWhenCreateCommandValid()
        {
            var command = new CreateCollegeCommand();

            command.FirstName = "FirstName";
            command.LastName  = "LastName";
            command.Document  = "34.469.528/0001-26";
            command.Email     = "*****@*****.**";
            command.Phone     = "00000000000";
            command.Image     = "image.jpeg";
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
        public void ShouldReturnInvalidWhenCreateCommandInvalid()
        {
            var command = new CreateCollegeCommand();

            command.FirstName = "";
            command.LastName  = "";
            command.Document  = "";
            command.Email     = "";
            command.Phone     = "";
            command.Image     = "";
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreNotEqual(true, result.Status);
        }
        public void ShouldReturnInvalidWhenEditCommandInvalid()
        {
            var command = new EditCollegeCommand();

            command.Id        = Guid.NewGuid();
            command.FirstName = "";
            command.LastName  = "";
            command.Document  = "";
            command.Email     = "example";
            command.Phone     = "";
            command.Image     = "";
            var handler = new CollegeHandler(new CollegeRepositoryMock(), new EmailServiceMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(false, result.Status);
        }
        protected void btnShow_Click(object sender, EventArgs e)
        {
            fld       = cboSearch.SelectedValue.ToString();
            txt       = txtSearch.Text;
            A_Handler = new CollegeHandler();
            sql       = "select * from " + Tbl_Name + " where " + fld + " like '" + txt + "%' ";
            //Grid1.DataSource = A_Handler.GetCollegeList(sql);
            //Grid1.DataBind();

            SqlDataSource1.SelectCommand = sql;
            SqlDataSource1.DataBind();
            if (Grid1.Rows.Count > 0)
            {
                lblRec.Text = "Total Records : " + Grid1.Rows.Count.ToString();
            }
            else
            {
                lblRec.Text = "Record Not Found...";
            }
        }
Example #7
0
 public CollegesController(ICollegeRepository repository, IEmailService emailService)
 {
     _repository   = repository;
     _emailService = emailService;
     _handler      = new CollegeHandler(_repository, emailService);
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            A_Handler = new CollegeHandler();
            A1        = new College();


            //A1.College_id = Convert.ToInt32(txtCollege_id.Text);
            A1.Reg_id       = Convert.ToInt32(ddlReg_id.SelectedValue);
            A1.College_Name = txtCollege_Name.Text;
            A1.Address      = txtAddress.Text;
            A1.City         = txtCity.Text;
            A1.Phone        = txtPhone.Text;
            A1.Mobile       = Convert.ToDecimal(txtMobile.Text);
            A1.Fax          = txtFax.Text;
            A1.Email        = txtEmail.Text;
            A1.Website      = txtWebsite.Text;
            A1.College_code = txtCollege_code.Text;
            A1.Prefix       = txtPrefix.Text;
            A1.Status       = Convert.ToInt32(DdlStatus.Text);



            if (btnSubmit.Text == "Submit")
            {
                bool B = A_Handler.AddNewCollege(A1);
                if (B == true)
                {
                    Label1.Text = "Record Inserted";
                    MSG         = "Record Inserted";
                }
                else
                {
                    Label1.Text = "Record Not Inserted";
                    MSG         = "Record Not Inserted";
                }
            }
            else if (btnSubmit.Text == "Update")
            {
                A1.College_id = Convert.ToInt32(txtCollege_id.Text);
                bool B = A_Handler.UpdateCollege(A1);
                if (B == true)
                {
                    Label1.Text = "Record Updated";
                    MSG         = "Record Not Updated";
                }
                else
                {
                    Label1.Text = "Record Not Updated";
                    MSG         = "Record Not Updated";
                }
            }
            else if (btnSubmit.Text == "Delete")
            {
                A1.College_id = Convert.ToInt32(txtCollege_id.Text);
                bool B = A_Handler.DeleteCollege(A1);
                if (B == true)
                {
                    Label1.Text = "Record Deleted";
                    MSG         = "Record Deleted";
                }
                else
                {
                    Label1.Text = "Record Not Deleted";
                    MSG         = "Record Not Deleted";
                }
            }

            //Response.Redirect("~/ADMIN/College_list.aspx?msg="+MSG);
        }