Exemplo n.º 1
0
        public async Task <IActionResult> Edit(AdTypeModel model)
        {
            if (ModelState.IsValid)
            {
                var awsService    = new AwsService <ICollection <AdType> >(_s3Client, AdSaleConstants.ConfigKey);
                var existingTypes = await awsService.GetObject(AdSaleConstants.TypeObjectKey);

                var adSaleType = existingTypes.First(x => x.Id == model.Id);
                adSaleType.Name = model.Name;
                adSaleType.AdditionalCharacterCount = model.AdditionalCharacterCount;
                adSaleType.AdditionalCharacterPrice = model.AdditionalCharacterPrice;
                adSaleType.BaseCharacterCount       = model.BaseCharacterCount;
                adSaleType.BaseCharacterPrice       = model.BaseCharacterPrice;
                adSaleType.HeaderPrice = model.HeaderPrice;
                adSaleType.MediaId     = model.MediaId;
                adSaleType.IsActive    = model.IsActive;

                await awsService.SaveObject(existingTypes, AdSaleConstants.TypeObjectKey);

                return(RedirectToAction("Index"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult Create()
        {
            var model = new AdTypeModel();
            var media = GetMedia();

            if (media.Result == null)
            {
                // no media registered so we cannot allow the creation of adsale types
                return(View("MediaMissing"));
            }

            model.Media    = media.Result;
            model.IsActive = true;
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(AdTypeModel model)
        {
            if (ModelState.IsValid)
            {
                var awsService    = new AwsService <ICollection <AdType> >(_s3Client, AdSaleConstants.ConfigKey);
                var existingTypes = await awsService.GetObject(AdSaleConstants.TypeObjectKey) ?? new List <AdType>();

                var typeToSave = _mapper.Map <AdType>(model);
                typeToSave.Id = IdGenerator.Make(existingTypes.Select(x => x.Id).ToList());

                existingTypes.Add(typeToSave);

                await awsService.SaveObject(existingTypes, AdSaleConstants.TypeObjectKey);

                return(RedirectToAction("Index"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }