コード例 #1
0
 public static OfferViewModel ConvertToOfferViewModel(Offer offer)
 {
     return new OfferViewModel
     {
         IdOffer = offer.IdOffer,
         IdUser = offer.IdUser,
         Type = offer.Type,
         NameOffer = offer.NameOffer,
         Description = offer.Description,
         Date = offer.Date.ToShortDateString()
      };
 }
コード例 #2
0
ファイル: OfferFacade.cs プロジェクト: SmallDev/OfferProject
        /// <summary> Сохранение или обновление информации по предложению </summary>
        public Boolean Save(Offer offer)
        {
            if (offer == null)
               throw new NullReferenceException("Не указано предложение");

            var result = new OfferValidator(offer).Validate();

            if ((result.Any())||((offer.IdOffer == 0) && (ExistOffers(offer.NameOffer))))
                return false;

            using (var dataManager = factory.GetDataManager(ConcurrencyLock.Optimistic))
            {
                var repository = dataManager.GetRepository<IOfferRepository>();
                repository.Save(offer);
                dataManager.Commit();
            }

            return true;
        }
コード例 #3
0
 public Offer Save(Offer offer)
 {
     int numEntr = -1;
     if (offer.IdOffer != 0)
     {
         Offer tempOffer = this.mContext.Offers.Where(c => c.IdOffer == offer.IdOffer).FirstOrDefault<Offer>();
       //  tempOffer.IdUser = offer.IdUser;
         tempOffer.NameOffer = offer.NameOffer;
      //   tempOffer.State = offer.State;
         tempOffer.Date = offer.Date;
         tempOffer.Description = offer.Description;
         tempOffer.Type = offer.Type;
       //  tempOffer.User = offer.User;
     }
     else
     {
         this.mContext.Offers.Add(offer);
     }
     numEntr = this.mContext.SaveChanges();
     if (numEntr > 0) return offer;
     return null;
 }
コード例 #4
0
ファイル: Test.cs プロジェクト: SmallDev/OfferProject
        private List<Offer> GetNewOffers()
        {
            var ListOffers = new List<Offer>();

            for(int i=0;i<1000;i++)
            {
                var tempOffer = new Offer()
                {
                    IdUser = 1,
                    NameOffer = "Hot Offer #"+i.ToString(),
                    Description ="Hey! New Year!!!",
                    Date=DateTime.Now+new TimeSpan(1,0,0,0),
                    Type=1,
                    State="Valid"
                };

                ListOffers.Add(tempOffer);

                tempOffer = new Offer()
                {
                    IdUser = 1,
                    NameOffer = "Cold Offer #" + i.ToString(),
                    Description = "Hey! New Year!!!",
                    Date = DateTime.Now + new TimeSpan(1, 0, 0, 0),
                    Type = 2,
                    State = "NoValid"
                };
                ListOffers.Add(tempOffer);
            }
            return ListOffers;
        }
コード例 #5
0
 public void Delete(Offer offer)
 {
     int numEntr = -1;
     this.mContext.Offers.Remove(offer);
     numEntr = this.mContext.SaveChanges();
 }