Exemplo n.º 1
0
        public static int AcceptOffer(ref Selling offer, Guid userId, out int historyId)
        {
            if (offer == null || offer.SellingId < 0 || userId == Guid.Empty || offer.SellerId == Guid.Empty)
              {
            throw new ArgumentNullException();
              }

              DataRow row;
              int res = SellingDataAdapter.AcceptOffer(offer.SellingId, userId, out historyId, out row);
              if (res == 1)
              {
            var user = UsersFacade.GetUser(offer.SellerId);
            if (user != null)
            {
              var msg = MessageFactory.CreateByTemplate(MessageTemplate.SellingAccepted
            , userId, null, new[] { offer.Title, user.UserName });
              MessageFacade.AddFromSystemUser(msg);
            }
              }

              if (row != null)
              {
            offer = offer.Load<Selling>(row);
              }

              return res;
        }
Exemplo n.º 2
0
        public static int ConflictOffer(ref Selling offer, Guid conflictUserId, out int historyId)
        {
            if (offer == null || offer.SellingId < 0 || offer.BuyerId == Guid.Empty
            || offer.SellerId == Guid.Empty || conflictUserId == Guid.Empty)
              {
            throw new ArgumentNullException();
              }

              if (conflictUserId != offer.SellerId && conflictUserId != offer.BuyerId)
              {
            throw new ArgumentException();
              }

              DataRow row;
              int res = SellingDataAdapter.ConflictOffer(offer.SellingId, conflictUserId, out historyId, out row);
              if (res == 1)
              {
            var conflictUser = UsersFacade.GetUser(conflictUserId);
            var msg = MessageFactory.CreateByTemplate(MessageTemplate.SellingConflicted, offer.SellerId,
            null, new[] { offer.Title, conflictUser.UserName });
            //to seller
            MessageFacade.AddFromSystemUser(msg);
            //to buyer
            msg.RecipientId = offer.BuyerId;
            MessageFacade.AddFromSystemUser(msg);
              }

              if (row != null)
              {
            offer = offer.Load<Selling>(row);
              }

              return res;
        }
Exemplo n.º 3
0
        public static int UpdateOfferKey(ref Selling offer, out int historyId)
        {
            if (offer == null || offer.SellingId < 0)
              {
            throw new ArgumentNullException();
              }

              DataRow row;
              int res = SellingDataAdapter.UpdateOfferKey(offer.SellingId, GenerateKey(7), out historyId, out row);

              if (row != null)
              {
            offer = offer.Load<Selling>(row);
              }

              return res;
        }
Exemplo n.º 4
0
        public static int ConfirmOffer(ref Selling offer, out int historyId)
        {
            if (offer == null || offer.SellingId < 0 || offer.BuyerId == Guid.Empty || offer.SellerId == Guid.Empty)
              {
            throw new ArgumentNullException();
              }

              DataRow row;
              int res = SellingDataAdapter.ConfirmOffer(offer.SellingId, GenerateKey(7)
              , TransferFactory.CreateBuyerToOffer(offer.BuyerId, offer, string.Empty)
              , out historyId, out row);
              if (res == 1)
              {
            var user = UsersFacade.GetUser(offer.BuyerId);
            if (user != null)
            {
              var msg = MessageFactory.CreateByTemplate(MessageTemplate.SellingConfirmed, offer.SellerId,
            null, new[] { user.UserName, offer.Title });
              MessageFacade.AddFromSystemUser(msg);
            }
              }

              if (row != null)
              {
            offer = offer.Load<Selling>(row);
              }

              return res;
        }