/// <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."); } }
/// <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); }