public bool AddCamera(Camera camera) { try { var insertCamera = mapper.Map <CodeFirstModels.Nomenclatures.Camera>(camera); using (var context = new KatDataContext()) { context.Cameras.Add(insertCamera); context.SaveChanges(); } return(true); } catch (Exception e) { return(false); } }
public bool UpdateCamera(Camera camera) { try { var updateCamera = mapper.Map <CodeFirstModels.Nomenclatures.Camera>(camera); using (var context = new KatDataContext()) { var dbRecord = context.Cameras.FirstOrDefault(v => v.Id == camera.Id); PropertyCopy.Copy(updateCamera, dbRecord); context.SaveChanges(); } return(true); } catch (Exception) { return(false); } }