Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }