public async Task <OperationDetails <int> > InitUpAd(int adId)
        {
            OperationDetails <int> operationDetail = new OperationDetails <int>(false, "", 0);

            var ad = await _uof.AdRepository.FindAdByIdAsync(adId);

            if (ad != null)
            {
                var adUp = new AdUp
                {
                    StartDateAction = DateTime.Now,
                    EndDateAction   = DateTime.Now.AddDays(30.0),
                    LastUp          = DateTime.Now,
                    LimitUp         = 10,
                    AdId            = ad.AdId
                };

                var result = await _uof.AdUpRepository.AddAsync(adUp);

                if (result != 0)
                {
                    operationDetail = new OperationDetails <int>(true, "", result);
                }
            }

            return(operationDetail);
        }
Example #2
0
        public async Task <int> Update(AdUp adUp)
        {
            try
            {
                _db.AdUps.Update(adUp);
                await _db.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(adUp.AdUpId);
        }