public Item Add(Item Item) { var item = _ItemRepository.Add(Item); _unitOfWork.Commit(); if (!string.IsNullOrEmpty(Item.Tags)) { string[] tags = Item.Tags.Split(','); for (var i = 0; i < tags.Length; i++) { var tagId = StringHelper.ToUnsignString(tags[i]); if (_tagRepository.Count(x => x.ID == tagId) == 0) { Tag tag = new Tag(); tag.ID = tagId; tag.Name = tags[i]; tag.Type = CommonConstants.ProductTag; _tagRepository.Add(tag); } ProductTag productTag = new ProductTag(); productTag.ProductID = Item.ID; productTag.TagID = tagId; _ItemTagRepository.Add(productTag); } } return(Item); }
public Order Post([FromServices] ICustomerRepository customerRepository, [FromServices] IOrderRepository orderRepository, [FromServices] IUniOfWork unityOfWork) { try { var customer = new Customer { Name = "Fernando Henrique Leme" }; var order = new Order { Number = "123", Customer = customer }; customerRepository.Save(customer); orderRepository.Save(order); unityOfWork.Commit(); return(order); } catch { unityOfWork.Rollback(); return(null); } }
public void Save() { _unitOfWork.Commit(); }
public void SaveChanges() { _unitOfWork.Commit(); }