public void AddOrder(MaterialDto m) { if (IsExist(m) == false) { db.Materials.Add(MaterialToDal(m)); db.SaveChanges(); } }
public Material MaterialToDal(MaterialDto mDto) { return(new Material() { Id = mDto.Id, MaterialCategoryId = mDto.MaterialCategoryId, Name = mDto.Name, }); }
public void UpdateMaterial(MaterialDto m) { Material Ezer = db.Materials.FirstOrDefault(x => x.Id == m.Id); if (Ezer != null) { Ezer.MaterialCategoryId = m.MaterialCategoryId; Ezer.Name = m.Name; db.SaveChanges(); } }
bool IsExist(MaterialDto m) { Boolean exist = false; db.Materials.ToList().ForEach(mat => { if (m.MaterialCategoryId == mat.MaterialCategoryId && m.Name.Equals(mat.Name)) { exist = true; } }); return(exist); }