Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you tell me why I am getting error on this line as the class is already exis

ID: 3583638 • Letter: C

Question

Can you tell me why I am getting error on this line as the class is already exist in the Model folder.

ManageProductType.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_Management_ManageProductTypes : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {

        ProductTypeModel model = new ProductTypeModel();
    }

    private ProductType createProductType()
    {
        ProductType p = new ProductType();
        p.Name = txtName.Text;

        return p;
    }
}

ProductTypeModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ProductTypeTypeModel
/// </summary>
public class ProductTypeModel
{
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return productType.Name + "was successfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }

    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            // Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return productType.Name + "was successfully updated";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }

    }

    public string DeleteProductType(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            ProductType productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();

            return productType.Name + "was successfully deleted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
}

X GarageManage Microsoft visual Studio (Administrator) J Quick Launch (Ctrl+Q) FILE EDIT VIEW WEBSITE BUILD DEBUG TEAM TOOLS TEST ANALYZE WINDOW HELP Ha s K Firefox C Debug Any CPU Solution Explorer Manage Product Types.aspx.cs X ManageProductTypes.aspx Pages Management ManageProduct btnSubmit Click (object sender, Event using System. eb.UI ebControls Search Solution Explorer (Ctrl+:) 4 App Code public partial class Pages Management ManageProductTy eb.UI system. Page Class Diagram.cd protected void Page Load (object sender, EventArgs e D E Model. Context,tt D S Model edmx D Model.tt protected void mit Click (object sender, EventArgs e mages 4 Models CartModel.cs Product Model model ne ProductT de l() ProductModel.cs The type or namespace name 'ProductTypeModel' could not be found (are you missing a using directive or an assembly reference?) Product TypeModel.cs ProductType createProduct Type() private Pages Management ProductType w ProductType() ne anage Product Types.aspx p Nam ame Text Solution Explorer Team Explorer Class View return p; Properties 100% Output Show output from: Build Building directory Pages /M anagement Building directory Pages Building directory Validation Complete -----E---- Build 1 succeeded or up-to-date, 0 failed, 0 skipped Error List Output Item(s) Saved Ln 18 Col 1 Ch 1 NS

Explanation / Answer

you are getting this error because you are not imported the class ProductTypeModel in your namespace. In order to resolve this you need to resolve the dependency, for that in visual studio just right click and select the resolve dependency, that will automatically reolve this kind of dependency problem.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote