Example #1
0
 public TagData TagCreat(TagData dataObject)
 {
     if (dataObject == null)
         throw new ArgumentNullException("tagDataObject");
     using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) {
         var tagRepository = context.GetRepository<Tag>();
         Tag tag = Mapper.Map<TagData, Tag>(dataObject);
         tagRepository.Add(tag);
         context.Commit();
         return Mapper.Map<Tag, TagData>(tag);
     }
 }
Example #2
0
 public void TagUpdate(TagData dataObject)
 {
     if (string.IsNullOrEmpty(dataObject.ID))
         throw new ArgumentNullException("ID");
     Tag replyChild = Mapper.Map<TagData, Tag>(dataObject);
     using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) {
         var tagRepository = context.GetRepository<Tag>();
         var upTag = tagRepository.Get(Specification<Tag>.Eval(c => c.ID.ToString() == dataObject.ID));
         if (!string.IsNullOrEmpty(dataObject.Name))
             upTag.Name = dataObject.Name;
         if (dataObject.GroupEnum != 0)
             upTag.GroupEnum = dataObject.GroupEnum;
         if (dataObject.ActEnum != 0)
             upTag.ActEnum = dataObject.ActEnum;
         if (dataObject.IsNecessary)
             upTag.IsNecessary = dataObject.IsNecessary;
         tagRepository.Update(upTag);
     }
 }