Пример #1
0
        private Author FillAuthor(SqlDataReader reader)
        {
            var author = new Author();
            author.Id = reader.GetInt32(0);
            author.Name = reader.GetString(1);
            author.Email = reader.GetString(2);
            author.Password = reader.GetString(3);
            author.IsActive = reader.GetBoolean(4);
            author.DateCreated = reader.GetDateTime(5);

            return author;
        }
Пример #2
0
        public void Update(Author obj)
        {
            var procedure = new ProcedureSql("Update_Author");

            procedure.AddParameter("@Id", obj.Id);
            procedure.AddParameter("@Name", obj.Name);
            procedure.AddParameter("@Email", obj.Email);
            procedure.AddParameter("@Password", obj.Password);
            procedure.AddParameter("@IsActive", obj.IsActive);

            procedure.Execute();          
        }
Пример #3
0
        public void Add(Author obj)
        {
            var procedure = new ProcedureSql("Add_Author");

            procedure.AddParameter("@Id", SqlDbType.Int, ParameterDirection.Output);
            procedure.AddParameter("@Name", obj.Name);
            procedure.AddParameter("@Email", obj.Email);
            procedure.AddParameter("@Password", obj.Password);
            procedure.AddParameter("@IsActive", obj.IsActive);
            procedure.AddParameter("@DateCreated", obj.DateCreated);

            obj.Id = procedure.Insert();            
        }
Пример #4
0
        public IValidationResult Add(Author obj)
        {
            if (obj == null)
                throw new NullReferenceException("obj");

            obj.DateCreated = DateTime.UtcNow;

            var validationResult = this.authorValidation.Validate(obj);

            if (validationResult.IsValid)
                this.authorRepository.Add(obj);

            return validationResult;
        }
Пример #5
0
        public IValidationResult Update(Author obj)
        {
            if (obj == null)
                throw new NullReferenceException("obj");

            var author = this.GetById(obj.Id);

            if (author == null)
                throw new Exception(string.Format("Author {0} not found.", obj.Id));

            author.IsActive = obj.IsActive;
            author.Name = obj.Name;
            author.Email = obj.Email;

            var validationResult = this.authorValidation.Validate(author);

            if (validationResult.IsValid)                
                this.authorRepository.Update(author);

            return validationResult;
        }
Пример #6
0
 public IValidationResult Update(Author obj)
 {
     return authorService.Update(obj);
 }
Пример #7
0
 public IValidationResult Add(Author obj)
 {            
     return authorService.Add(obj);
 }