예제 #1
0
 // PUT: api/AdMedia/5
 public bool Put(int id, [FromBody] AdMediaEntity AdMediaEntity)
 {
     if (id > 0)
     {
         return(_AdMediaServices.UpdateAdMedia(id, AdMediaEntity));
     }
     return(false);
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
 // POST: api/AdMedia
 public int Post([FromBody] AdMediaEntity AdMediaEntity)
 {
     return(_AdMediaServices.CreateAdMedia(AdMediaEntity));
 }