/// <summary>
        ///
        /// </summary>
        /// <param name="attrib"></param>
        /// <returns></returns>
        public TestTemplateAttributeDto Addattribute(TestTemplateAttribute attrib)
        {
            TestTemplateAttributeRepository repo = new TestTemplateAttributeRepository();

            MapperConfig.ConfigAutoMapper();

            if (this.IsValidAttribute(attrib))
            {
                if (repo.GetAttribute(attrib.Attribute) == null)
                {
                    attrib.CreatedDate  = DateTime.Now;
                    attrib.CreatedBy    = "MLT";
                    attrib.ModifiedBy   = null;
                    attrib.ModifiedDate = null;

                    var saveattrib = repo.Insert(Mapper.Map <TestTemplateAttribute>(attrib));

                    return(Mapper.Map <TestTemplateAttributeDto>(attrib));
                }
                else

                {
                    throw new InvalidOperationException("Template is not acceptable.Already saved template");
                }
            }
            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="templateId"></param>
        /// <returns></returns>
        public IList <TestTemplateAttributeDto> GetTestTemplateAttributes(int templateId)
        {
            if (templateId > 0)
            {
                TestTemplateAttributeRepository attrRepo = new TestTemplateAttributeRepository();
                var attrList = attrRepo.SearchFor(p => p.TemplateID == templateId);


                return(Mapper.Map <List <TestTemplateAttributeDto> >(attrList));
            }
            else
            {
                return(new List <TestTemplateAttributeDto>());
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="attrib"></param>
        /// <returns></returns>
        public TestTemplateAttributeDto Updateattribute(TestTemplateAttribute attrib)
        {
            TestTemplateAttributeRepository repo = new TestTemplateAttributeRepository();

            attrib.CreatedDate = repo.GetAttribute(attrib.Attribute).CreatedDate;

            attrib.AttrID = repo.GetAttribute(attrib.Attribute).AttrID;

            attrib.TemplateID = repo.GetAttribute(attrib.Attribute).TemplateID;

            attrib.CreatedBy = repo.GetAttribute(attrib.Attribute).CreatedBy;

            MapperConfig.ConfigAutoMapper();

            {
                repo.Update(Mapper.Map <TestTemplateAttribute>(attrib));
            }

            return(null);
        }
 public TestTemplateAttributeHelper()
 {
     TestTemplateAttribRepo = new TestTemplateAttributeRepository();
 }