Esempio n. 1
0
        public bool AddPhysicUser(Model.PhysicUser entity)
        {
            var vallidtion = new PhysicUserValidation.PhysicUserEntityValidation().Validate(entity);

            if (!vallidtion.IsValid)
            {
                throw new ValidationException(vallidtion.Errors);
            }

            using (var db = new Model.PhysicManagementEntities())
            {
                entity.Password = EncryptPassword(entity.Username, entity.Password);
                db.PhysicUser.Add(entity);
                return(db.SaveChanges() == 1);
            }
        }
Esempio n. 2
0
        public bool UpdatePhysicUser(Model.PhysicUser entity)
        {
            //var vallidtion = new PhysicUserValidation.PhysicUserEntityValidation().Validate(entity);
            //if (!vallidtion.IsValid)
            //    throw new ValidationException(vallidtion.Errors);

            using (var db = new PhysicManagementEntities())
            {
                var Entity = db.PhysicUser.Find(entity.Id);
                Entity.FirstName   = entity.FirstName;
                Entity.LastName    = entity.LastName;
                Entity.Username    = entity.Username;
                Entity.Password    = EncryptPassword(entity.Username, entity.Password);
                Entity.Mobile      = entity.Mobile;
                Entity.Gender      = entity.Gender;
                Entity.Description = entity.Description;
                Entity.Gender      = entity.Gender;

                return(db.SaveChanges() == 1);
            }
        }