Can you tell me why I am getting this error? I am using 2013 version. ManageProd
ID: 3583677 • Letter: C
Question
Can you tell me why I am getting this error? I am using 2013 version.
ManageProductType.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using productTypeModelName;
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.ProductType pt = new ProductTypeModel.ProductType();
ProductTypeModel model = new ProductTypeModel();
ProductType pt = CreateProductType();
lblResult.Text = model.InsertProductType(pt);
}
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 description for ProductTypeTypeModel
///
namespace productTypeModelName
{
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) Quick Launch (Ctrl+Q) FILE EDIT VIEW PROJECT BUILD DEBUG TEAM TOOLS TEST ANALYZE WINDOW HELP Ha s K Firefox Product TypeModel.cs Manage ProductTypes.aspx.cs X Manage ProductTypes.aspx 2 Solution Explorer O Pages Management ManageProduct Page Load(object sender, EventArgs E using System Search Solution Explorer (Ctrl+ using System Collections. Gene Solution 'GarageManager d project using System.Linq; using System. eb 4 e Garage Manager using System. eb.UI App Code eb.UI ebControls using System. mages ductT using pro ame Models CartModel.cs El public partial class Pages Management ManageProductTypes system. eb.UI Page CH: ProductModel.cs protected void Page Load (object sende EventArgs CH Product Type MModel.cs Pages Management D Manageproducts.aspx E protected void btnsubmit Click (object sende EventArgs e) Manage Product Types aspx //Product TypeModel .ProductType pt ProductTypeModel. ProductType ne ProductT Model model ProductT de l() Solution Explorer Team Explorer Class View ne ProductType pt Create ProductT Properties lblResult model. Product Type (pt) Te Insert Garage Manager Solution Properties 100% Error List Misc Search Error List Name Garage Manager 4 Errors 0 Messages DebuglAny CPU Active config Description File Column Project ne Description X1 ManageProductTypes 8 GarageManage he type or namespace name Path C:UsersUserDocume productType ModelName could not be found Startup project Garage Manager you missing a using directive or an assembly are reference?) Name) 2 The type or namespace name Manage ProductTypes 19 GarageManage The name of the solution file ProductType Model could not be found (are you Error List Output Ready Ln 7 Col 1 Ch 1 NSExplanation / Answer
Answer :
ManageProductType.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using productTypeModelName;
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.ProductType pt = new ProductTypeModel.ProductType();
ProductTypeModel model = new ProductTypeModel();
ProductType pt = CreateProductType();
lblResult.Text = model.InsertProductType(pt);
}
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 description for ProductTypeTypeModel
///
namespace productTypeModelName
{
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;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.