Exemplo n.º 1
0
 /// <summary>
 /// Creates a dairy
 /// </summary>
 /// <param name="dairyEntity"></param>
 /// <returns></returns>
 public double CreateDairy(BusinessEntities.DairyEntity dairyEntity)
 {
     using (var scope = new TransactionScope())
     {
         var dairy = new DOC_RECEIVING_HEADER
         {
             HEADER_ID_PK = dairyEntity.HEADER_ID_PK
         };
         _unitOfWork.DairyRepository.Insert(dairy);
         _unitOfWork.Save();
         scope.Complete();
         return(dairy.HEADER_ID_PK);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates a dairy
        /// </summary>
        /// <param name="dairyId"></param>
        /// <param name="dairyEntity"></param>
        /// <returns></returns>
        public bool UpdateDairy(int dairyId, BusinessEntities.DairyEntity dairyEntity)
        {
            var success = false;

            if (dairyEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var dairy = _unitOfWork.DairyRepository.GetByID(dairyId);
                    if (dairy != null)
                    {
                        dairy.HEADER_ID_PK = dairyEntity.HEADER_ID_PK;
                        _unitOfWork.DairyRepository.Update(dairy);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }