private TypesOfProductType CreateTypesOfProductType() { TypesOfProductType p = new TypesOfProductType(); p.Name = TxtName.Text; p.TypeID = Convert.ToInt32(DdlType.SelectedValue); return(p); }
protected void BtnSend_Click(object sender, EventArgs e) { TypesOfProductTypeModel model = new TypesOfProductTypeModel(); TypesOfProductType pt = CreateTypesOfProductType(); LblResult.Text = model.InsertTypesOfProductType(pt); TxtName.Text = string.Empty; }
public string InsertTypesOfProductType(TypesOfProductType typesOfProductType) { try { Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities(); db.TypesOfProductTypes.Add(typesOfProductType); db.SaveChanges(); return(typesOfProductType.Name + " uspješno je umetnuto"); } catch (Exception e) { return("Error" + e); } }
public string UpdateTypesOfProductType(int id, TypesOfProductType typesOfProductType) { try { Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities(); TypesOfProductType p = db.TypesOfProductTypes.Find(id); p.Name = typesOfProductType.Name; p.TypeID = typesOfProductType.TypeID; db.SaveChanges(); return(typesOfProductType.Name + "uspješno je ažurirano"); } catch (Exception e) { return("Error" + e); } }
public string DeleteTypesOfProductType(int id) { try { Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities(); TypesOfProductType typesOfProductType = db.TypesOfProductTypes.Find(id); db.TypesOfProductTypes.Attach(typesOfProductType); db.TypesOfProductTypes.Remove(typesOfProductType); db.SaveChanges(); return(typesOfProductType.Name + "uspješno je obrisano"); } catch (Exception e) { return("Error" + e); } }