// PUT: api/AdMedia/5 public bool Put(int id, [FromBody] AdMediaEntity AdMediaEntity) { if (id > 0) { return(_AdMediaServices.UpdateAdMedia(id, AdMediaEntity)); } return(false); }
public int CreateAdMedia(AdMediaEntity adMediaEntity) { using (var scope = new TransactionScope()) { var adMedia = new AdMedia() { id = adMediaEntity.id, name = adMediaEntity.name, description = adMediaEntity.description }; _unitOfWork.AdMediaRepository.Insert(adMedia); _unitOfWork.Save(); scope.Complete(); return(adMedia.id); } }
public bool UpdateAdMedia(int adMediaId, AdMediaEntity adMediaEntity) { var success = false; if (adMediaEntity != null) { using (var scope = new TransactionScope()) { var adMedia = _unitOfWork.AdMediaRepository.GetByID(adMediaId); if (adMedia != null) { adMedia.id = adMediaEntity.id; adMedia.name = adMediaEntity.name; adMedia.description = adMediaEntity.description; _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
// POST: api/AdMedia public int Post([FromBody] AdMediaEntity AdMediaEntity) { return(_AdMediaServices.CreateAdMedia(AdMediaEntity)); }