Пример #1
0
 public CommandResult Save(BlockInfo command)
 {
     try
     {
         int       blockId = command.BlockId;
         string    result  = "";
         BlockInfo block   = new BlockInfo();
         Tools.CopyClass(block, command);
         var IsExist = _unitOfWork.GenericRepositories <BlockInfo>().FindBy(x => x.BlockId == command.BlockId)?.FirstOrDefault();
         if (IsExist == null)
         {
             _unitOfWork.GenericRepositories <BlockInfo>().Insert(block);
             result = _unitOfWork.SaveChange();
             LogEventStore(block.BlockId.ToString(), GetType().Name, "Save");
         }
         else
         {
             block.BlockId = IsExist.BlockId;
             _unitOfWork.GenericRepositories <BlockInfo>().Update(block);
             result = _unitOfWork.SaveChange();
             LogEventStore(block.BlockId.ToString(), GetType().Name, "Update");
         }
         return(ResponseBase.CommandResultSuccess(result, blockId, block.BlockId));
     }
     catch (Exception ex)
     {
         return(ResponseBase.CommandResultError(ex.Message, command.BlockId));
     }
 }