public void TestEditProvider()
        {
            ProviderController pc = new ProviderController();

            System.Web.Mvc.ViewResult result = pc.Index(null);

            Provider p = ((IPagedList <Provider>)result.ViewData.Model).First();

            System.Web.Mvc.ActionResult customerEdition = pc.Edit(p.ProviderID);

            //post edited
            p.Address       = "Address dummy";
            p.City          = "City dummy";
            p.CompanyNumber = "23423423424";
            p.CP            = "508000";
            p.Email         = "*****@*****.**";
            p.Fax           = "342343434";
            p.Name          = "Company name dummy";
            p.Phone1        = "3423423423";
            p.Phone2        = "234234232";

            System.Web.Mvc.ActionResult resultEditionView = pc.Edit(p.ProviderID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultEditionView);

            System.Web.Mvc.ActionResult resultEdition = pc.Edit(p);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.RedirectToRouteResult), resultEdition);
        }
Exemple #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string res = "";
         if (this.txtBusinessname.Text == string.Empty || this.txtNumdoc.Text == string.Empty || this.txtAddress.Text == string.Empty)
         {
             MessageError("Faltan datos obligatorios");
             errorInput.SetError(txtBusinessname, "Introduzca un valor");
             errorInput.SetError(txtNumdoc, "Introduzca un valor");
             errorInput.SetError(txtAddress, "Introduzca un valor");
         }
         else
         {
             if (this.IsNew)
             {
                 res = ProviderController.Insert(this.txtBusinessname.Text.Trim(), this.cbxSector.Text, this.cbxTypedoc.Text, this.txtNumdoc.Text, this.txtAddress.Text, this.txtPhone.Text, this.txtMobile.Text, this.txtFax.Text, this.txtEmail.Text, this.txtWeb.Text);
             }
             else
             {
                 res = ProviderController.Edit(Convert.ToInt32(this.txtIdprovider.Text), this.txtBusinessname.Text.Trim(), this.cbxSector.Text, this.cbxTypedoc.Text, this.txtNumdoc.Text, this.txtAddress.Text, this.txtPhone.Text, this.txtMobile.Text, this.txtFax.Text, this.txtEmail.Text, this.txtWeb.Text);
             }
             if (res.Equals("Correcto"))
             {
                 if (this.IsNew)
                 {
                     this.MessageOK("¡Se ha insertado el registro!");
                 }
                 else
                 {
                     this.MessageOK("¡Se ha modificado el registro!");
                 }
             }
             else
             {
                 this.MessageError(res);
             }
             this.IsNew  = false;
             this.IsEdit = false;
             this.EnableButtons();
             this.ResetForm();
             this.ShowData();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }