コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ErrorLabel.Visible = false;
            if (Session["email"] != null)
            {
                User u = UserController.GetUser(Session["email"].ToString());

                if (u.RoleID == 1)
                {
                    if (Request.QueryString["protypeid"] != null)
                    {
                        protypeid = int.Parse(Request.QueryString["protypeid"]);
                        pro       = ProductTypeController.GetProductType(protypeid);
                        if (!IsPostBack)
                        {
                            proTypeText.Text = pro.Name.ToString();
                            descTxt.Text     = pro.Description.ToString();
                        }
                    }
                    else
                    {
                        Response.Redirect("ViewProductType.aspx");
                    }
                }
                else
                {
                    CantAccessView();
                }
            }
            else
            {
                CantAccessView();
            }
        }
コード例 #2
0
        private void setDataForm(int id)
        {
            var productData = typeController.GetProductType(id);

            if (productData == null)
            {
                Response.Redirect(Constants.Routes.PRODUCT_TYPE_ROUTE);
                return;
            }
            txtnameold.Attributes["Value"] = productData.Name.ToString();
            txtname.Attributes["Value"]    = productData.Name.ToString();
            txtdesc.InnerHtml = productData.Description.ToString();
        }
コード例 #3
0
        public async Task Invalid_Id_Returns_Null()
        {
            var id          = Guid.NewGuid();
            var productType = ProductType.Create(id, "type");

            var mockProductTypeService = new Mock <IProductTypeService>();

            mockProductTypeService.Setup(s => s.GetProductTypeAsync(Guid.NewGuid()))
            .Returns(() => Task.FromResult(productType));

            var productTypeController = new ProductTypeController(mockProductTypeService.Object);

            var result = await productTypeController.GetProductType(id);

            Assert.Null(result);
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ProductTypeController pt = new ProductTypeController();
         Uri    myUri             = new Uri(Request.Url.ToString());
         string ProductTypeId     = HttpUtility.ParseQueryString(myUri.Query).Get("ID");
         if (ProductTypeId == null)
         {
             Response.Redirect("ListProductTypes.aspx");
         }
         pt.GetProductType(int.Parse(ProductTypeId));
         ProductType.Text = pt.ProductType;
         lblFileUploadProductTypePicturePath.Text = pt.ProductTypePicture;
         LanguageController lc = new LanguageController();
         ddlLanguageId.DataSource     = lc.GetLanguages();
         ddlLanguageId.DataTextField  = "LanguageTitle";
         ddlLanguageId.DataValueField = "LanguageID";
         ddlLanguageId.DataBind();
         ddlLanguageId.SelectedValue = pt.LanguageID.ToString();
     }
 }