Exemplo n.º 1
0
        public async Task <ActionResult> SetState(int?id)
        {
            var HomePage = await db.HomePages.FindAsync(id);

            if (HomePage != null)
            {
                var HomePageActive = await GetActiveHomePage();

                if (HomePageActive != null)
                {
                    if (!HomePage.HomePageActive)
                    {
                        HomePage.HomePageActive        = true;
                        HomePageActive.HomePageActive  = false;
                        db.Entry(HomePage).State       = EntityState.Modified;
                        db.Entry(HomePageActive).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        var HomePages = db.HomePages.Include(h => h.BlogSection).Include(h => h.CardSection).Include(h => h.FoseSection).Include(h => h.OfferSection);
                        return(View("Index", await HomePages.ToListAsync()));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SetState(int?id)
        {
            MailConfiguration mailConfiguration = await context.MailConfigurations.FindAsync(id);

            MailConfiguration currentConficuration = await context.MailConfigurations.Where(mc => mc.Active == true).FirstOrDefaultAsync();



            if (mailConfiguration == null && currentConficuration == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            if (currentConficuration == null && mailConfiguration != null)
            {
                mailConfiguration.Active = true;
                context.Entry(mailConfiguration).State = EntityState.Modified;
            }
            else
            {
                currentConficuration.Active = false;
                mailConfiguration.Active    = true;

                context.Entry(currentConficuration).State = EntityState.Modified;
                context.Entry(mailConfiguration).State    = EntityState.Modified;
            }

            await context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> SetState(int?id)
        {
            var OfferPage = await db.OfferPages.FindAsync(id);

            if (OfferPage != null)
            {
                var OfferPageActive = await GetActiveOfferPage(OfferPage.OfferTypeId);

                if (OfferPageActive != null)
                {
                    if (!OfferPage.OfferPageActive)
                    {
                        OfferPage.OfferPageActive       = true;
                        OfferPageActive.OfferPageActive = false;
                        db.Entry(OfferPage).State       = EntityState.Modified;
                        db.Entry(OfferPageActive).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        var OfferPages = db.OfferPages.Include(x => x.OfferType);
                        return(View("Index", await OfferPages.ToListAsync()));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
        public async Task <ActionResult> SetState(int?id)
        {
            var BillingPage = await db.BillingPages.FindAsync(id);

            if (BillingPage != null)
            {
                var BillingPageActive = await GetActiveBillingPage();

                if (BillingPageActive != null)
                {
                    if (!BillingPage.BillingPageActive)
                    {
                        BillingPage.BillingPageActive       = true;
                        BillingPageActive.BillingPageActive = false;
                        db.Entry(BillingPage).State         = EntityState.Modified;
                        db.Entry(BillingPageActive).State   = EntityState.Modified;
                        await db.SaveChangesAsync();

                        var BillingPages = db.BillingPages.Include(h => h.BenefitSection).Include(h => h.IncrementBenefitSection).Include(h => h.LabSection);
                        return(View("Index", await BillingPages.ToListAsync()));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> ActiveConfirmed(int id)
        {
            var BlogPage = await db.BlogPages.FindAsync(id);

            if (BlogPage != null)
            {
                var BlogPageActive = await GetActiveBlogPage(BlogPage.BlogTypeId);

                if (BlogPageActive != null)
                {
                    if (BlogPage.BlogPageActive == "EnEdicion" || BlogPage.BlogPageActive == "Desactivada")
                    {
                        BlogPage.BlogPageActive = "Activada";
                        foreach (var newsPage in BlogPage.News)
                        {
                            newsPage.NewsPageActive = "Activada";
                        }

                        BlogPageActive.BlogPageActive = "Desactivada";
                        foreach (var newsPage in BlogPageActive.News)
                        {
                            newsPage.NewsPageActive = "Desactivada";
                        }

                        db.Entry(BlogPage).State       = EntityState.Modified;
                        db.Entry(BlogPageActive).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
        public async Task <AdministrationServiceResult> create(BranchInputModel inputData)
        {
            AdministrationServiceResult result = new AdministrationServiceResult();

            var state = context.Estados.Where(st => st.Id == inputData.State).FirstOrDefault();

            if (state != null)
            {
                var city = context.Municipios.Where(c => c.Id == inputData.City).FirstOrDefault();
                if (city != null)
                {
                    if (inputData.BranchName.Trim().Length != 0)
                    {
                        if (inputData.BranchAddress.Trim().Length != 0)
                        {
                            Branch branch = getTargetBranch(inputData);

                            if (branch != null)
                            {
                                branch.State = state;
                                branch.City  = city;
                                if (inputData.BranchId == 0)
                                {
                                    context.Branchs.Add(branch);
                                }
                                else
                                {
                                    context.Entry(branch).State = System.Data.Entity.EntityState.Modified;
                                }
                            }
                            else
                            {
                                result.Errors.Add("Sucursal no válida");
                            }
                            await context.SaveChangesAsync();
                        }
                        else
                        {
                            result.Errors.Add("Dirección de sucursal no válida");
                        }
                    }
                    else
                    {
                        result.Errors.Add("Nombre de sucursal no válido");
                    }
                }
                else
                {
                    result.Errors.Add("Ciudad no válida");
                }
            }
            else
            {
                result.Errors.Add("Estado no válido");
            }

            return(result);
        }
Exemplo n.º 7
0
        public async Task <ActionResult> ActiveConfirmed(int id)
        {
            FosePage FosePage = await db.FosePages.FindAsync(id);

            if (FosePage != null)
            {
                var FosePageActive = await GetActiveFosePage();

                if (FosePageActive != null)
                {
                    if (FosePage.FosePageActive == "EnEdicion" || FosePage.FosePageActive == "Desactivada")
                    {
                        FosePage.FosePageActive = "Activada";
                        foreach (var promocionPage in FosePage.Promocions)
                        {
                            promocionPage.PromocionPageActive = "Activada";
                            foreach (var productPage in promocionPage.ProductPages)
                            {
                                productPage.ProductPageActive = "Activada";
                            }
                        }

                        FosePageActive.FosePageActive = "Desactivada";
                        foreach (var promocionPage in FosePageActive.Promocions)
                        {
                            promocionPage.PromocionPageActive = "Desactivada";
                            foreach (var productPage in promocionPage.ProductPages)
                            {
                                productPage.ProductPageActive = "Desactivada";
                            }
                        }

                        db.Entry(FosePage).State       = EntityState.Modified;
                        db.Entry(FosePageActive).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "SaDTypeNumberId,SaDTypeNumberCity,SaDTypeNumberPhone,SaDTypeNumberActive")] SaDTypeNumber saDTypeNumber)
        {
            if (ModelState.IsValid)
            {
                db.Entry(saDTypeNumber).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(saDTypeNumber));
        }
Exemplo n.º 9
0
        public async Task <ActionResult> Edit([Bind(Include = "ServiceTypeId,ServiceTypeName,ServiceTypeNameDescription,ServiceTypeProdutcsDescription,ServiceTypeActive")] ServiceType serviceType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(serviceType).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(serviceType));
        }
        public async Task <ActionResult> Edit([Bind(Include = "ReportTypeId,ReportName,ReportDescription,ReportActive")] ReportType reportType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(reportType).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(reportType));
        }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "EntryNo,AlbumNo,RecordCompany,ReleaseCode")] Release release)
 {
     if (ModelState.IsValid)
     {
         db.Entry(release).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AlbumNo = new SelectList(db.Album, "EntryNo", "Author", release.AlbumNo);
     return(View(release));
 }
Exemplo n.º 12
0
 //public ActionResult Edit([Bind(Include = "EntryNo,Author,Title,Duration,YearOfProduction")] Album album)
 public ActionResult Edit(Tuple <Album, ICollection <Photo> > albumPlusPhotos)
 {
     if (ModelState.IsValid)
     {
         var album = albumPlusPhotos.Item1;
         db.Entry(album).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(albumPlusPhotos));
     //return View(album);
 }
        public async Task <ActionResult> Edit(int?id)
        {
            var  idBlog      = 0;
            var  name        = "";
            bool active      = false;
            var  httpRequest = System.Web.HttpContext.Current.Request;

            foreach (var form in httpRequest.Form.AllKeys)
            {
                var formValue = httpRequest.Form[form];
                formValue = string.IsNullOrEmpty(formValue) ? null : formValue;
                switch (form)
                {
                case "IdTipoBlog":
                    idBlog = int.Parse(formValue);
                    break;

                case "NombreTipoBlog":
                    name = formValue.Trim();
                    break;

                case "EstadoTipoBlog":
                    active = formValue == "true";
                    break;
                }
            }

            var offe = await db.BlogTypes.FirstOrDefaultAsync(x => x.BlogTypeName == name && x.BlogTypeId != idBlog);

            if (offe == null)
            {
                var blogType = await db.BlogTypes.FindAsync(idBlog);

                if (blogType != null)
                {
                    blogType.BlogTypeName    = name;
                    blogType.BlogTypeActive  = active;
                    db.Entry(blogType).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(Json(new AjaxResponse {
                        Success = true, Message = "La Categoría se actualizó correctamente"
                    }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new AjaxResponse {
                Success = false, Message = "Ya existe una Categoría con ese nombre"
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 14
0
        public async Task <ActionResult> SetState(int?id)
        {
            var SaDPage = await db.SaDPages.FindAsync(id);

            if (SaDPage != null)
            {
                var SaDPageActive = await GetActiveSaDPage();

                if (SaDPageActive != null)
                {
                    if (!SaDPage.SaDPageActive)
                    {
                        SaDPage.SaDPageActive         = true;
                        SaDPageActive.SaDPageActive   = false;
                        db.Entry(SaDPage).State       = EntityState.Modified;
                        db.Entry(SaDPageActive).State = EntityState.Modified;
                        await db.SaveChangesAsync();

                        return(View("Index", await db.SaDPages.ToListAsync()));
                    }
                }
            }
            return(RedirectToAction("NotFound", "Error"));
        }
Exemplo n.º 15
0
        public ActionResult Edit([Bind(Include = "EntryNo,AlbumNo,ReleaseNo,FilePath,UserUploaded")] Photo photo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(photo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.AlbumNo   = new SelectList(db.Album, "EntryNo", "MetaDescription");
            ViewBag.ReleaseNo = new SelectList(db.Release.Where(c => c.AlbumNo == photo.AlbumNo).ToList(), "EntryNo", "MetaDescription");

            //ViewBag.AlbumNo = new SelectList(db.Album, "EntryNo", "Author", photo.AlbumNo);
            //ViewBag.ReleaseNo = new SelectList(db.Release, "EntryNo", "EntryNo", photo.ReleaseNo);
            return(View(photo));
        }
        public async Task <ActionResult> ConfirmAddOrEdit(InterestRegion model)
        {
            if (ModelState.IsValid == false)
            {
                return(View("AddOrEdit", model));
            }
            if (model.Id > 0)
            {
                var offe = await db.InterestRegions.FirstOrDefaultAsync(x => x.Name == model.Name && x.Id != model.Id);

                if (offe == null)
                {
                    var interestRegion = await db.InterestRegions.FindAsync(model.Id);

                    if (interestRegion != null)
                    {
                        interestRegion.Name            = model.Name;
                        interestRegion.Active          = model.Active;
                        interestRegion.MailCollection  = model.MailCollection;
                        db.Entry(interestRegion).State = EntityState.Modified;
                        await db.SaveChangesAsync();
                    }
                }
            }
            else
            {
                var region = await db.InterestRegions.FirstOrDefaultAsync(a => a.Name == model.Name);

                if (region == null)
                {
                    region = new InterestRegion()
                    {
                        CreationDate   = DateTime.Now,
                        Name           = model.Name,
                        Active         = model.Active,
                        MailCollection = model.MailCollection
                    };
                    db.InterestRegions.Add(region);
                    await db.SaveChangesAsync();
                }
                else
                {
                    ModelState.AddModelError("", "Ya existe una región con el nombre " + model.Name);
                    return(View("AddOrEdit", model));
                }
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "UserNo,AlbumNo,ReleaseNo,Comment")] CollectionEntry collectionEntry)
        {
            //wyłąono możliwosć edycji
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Brak możliwości edycji"));

            if (ModelState.IsValid)
            {
                db.Entry(collectionEntry).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.AlbumNo   = new SelectList(db.Album, "EntryNo", "Author", collectionEntry.AlbumNo);
            ViewBag.ReleaseNo = new SelectList(db.Release, "EntryNo", "RecordCompany", collectionEntry.ReleaseNo);
            ViewBag.UserNo    = new SelectList(db.Users, "Id", "Email", collectionEntry.UserNo);
            return(View(collectionEntry));
        }
Exemplo n.º 18
0
        private AdministrationServiceResult updateLaboratory(LaboratoryInputModel inputData, Municipios city, Estados state)
        {
            AdministrationServiceResult result = new AdministrationServiceResult();
            var laboratory = context.Laboratories.Where(l => l.ID == inputData.Id).FirstOrDefault();

            if (laboratory != null)
            {
                laboratory.Name   = inputData.Name;
                laboratory.Active = inputData.Active;
                laboratory.City   = city;
                laboratory.State  = state;
                context.Entry(laboratory).State = EntityState.Modified;
            }
            else
            {
                result.Errors.Add("Laboratorio no válido");
            }
            return(result);
        }
Exemplo n.º 19
0
        public async Task <AdministrationServiceResult> create(PillarInputModel inputData)
        {
            AdministrationServiceResult result = new AdministrationServiceResult();

            if (inputData.PillarName.Trim().Length != 0)
            {
                if (inputData.PillarDescription.Trim().Length != 0)
                {
                    Pillar pillar = getTargetPillar(inputData);

                    if (pillar != null)
                    {
                        if (inputData.PillarId == 0)
                        {
                            context.Pillars.Add(pillar);
                        }
                        else
                        {
                            context.Entry(pillar).State = System.Data.Entity.EntityState.Modified;
                        }
                    }
                    else
                    {
                        result.Errors.Add("Pilar no válido");
                    }
                    await context.SaveChangesAsync();
                }
                else
                {
                    result.Errors.Add("Descripción de pilar no válida");
                }
            }
            else
            {
                result.Errors.Add("Nombre de pilar no válido");
            }

            return(result);
        }
 public IActionResult Edit(Question question)
 {
     _db.Entry(question).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 21
0
        private async Task <JsonResult> PrepareDataFiles(FileType all)
        {
            var    httpRequest = System.Web.HttpContext.Current.Request;
            string pillarLink = "", pillarName = "", pillarImage = "", pillarDescription = "";
            bool   pillarActive = false;
            bool   seSubio      = false;
            int    pillarId     = 0;

            foreach (string file in httpRequest.Files)
            {
                var postedFile = httpRequest.Files[file];
                var valid      = Utils.IsValidImage(postedFile, all);

                if (valid.Value == "Ok")
                {
                    if (postedFile != null)
                    {
                        var fil          = $"{Path.GetFileNameWithoutExtension(postedFile.FileName)}_{DateTime.Now.Ticks}{postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'))}";
                        var fileSavePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles"), fil);
                        if (!postedFile.FileName.StartsWith("/"))
                        {
                            postedFile.SaveAs(fileSavePath);
                            seSubio = true;
                            switch (file)
                            {
                            case "PillarImage":
                                pillarImage = $"{"~/UploadedFiles"}/{fil}";
                                break;
                            }
                        }
                    }
                }
                else
                {
                    return(Json(new AjaxResponse {
                        Success = false, Message = valid.Value
                    }, JsonRequestBehavior.AllowGet));
                }
            }

            foreach (var form in httpRequest.Form.AllKeys)
            {
                var formValue = httpRequest.Form[form];
                formValue = string.IsNullOrEmpty(formValue) ? null : formValue;
                switch (form)
                {
                case "PillarName":
                    pillarName = formValue;
                    break;

                case "PillarDescription":
                    pillarDescription = formValue;
                    break;

                case "PillarLink":
                    pillarLink = formValue;
                    break;

                case "PillarActive":
                    pillarActive = formValue == "true";
                    break;

                case "PillarId":
                    pillarId = Convert.ToInt32(formValue);
                    break;
                }
            }

            if (seSubio)
            {
                if (!string.IsNullOrEmpty(pillarName) && !string.IsNullOrEmpty(pillarDescription))
                {
                    if (pillarId == 0)
                    {
                        db.Pillars.Add(new Pillar
                        {
                            PillarImage       = pillarImage,
                            PillarName        = pillarName,
                            PillarDescription = pillarDescription,
                            PillarLink        = pillarLink,
                            PillarActive      = pillarActive
                        });
                    }
                    else
                    {
                        Pillar pillar = await db.Pillars.FindAsync(pillarId);

                        if (pillar != null)
                        {
                            pillar.PillarImage       = pillarImage;
                            pillar.PillarName        = pillarName;
                            pillar.PillarDescription = pillarDescription;
                            pillar.PillarLink        = pillarLink;
                            pillar.PillarActive      = pillarActive;
                            db.Entry(pillar).State   = EntityState.Modified;
                        }
                    }
                    await db.SaveChangesAsync();
                }

                return(Json(new AjaxResponse {
                    Success = true, Message = "Los datos fueron subidos correctamente al servidor"
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new AjaxResponse {
                Success = false, Message = "Ocurrió un error al subir lo(s) archivo(s)."
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 22
0
        private async Task <JsonResult> PrepareDataFiles(FileType all)
        {
            var    httpRequest = System.Web.HttpContext.Current.Request;
            string quoteText = "", quoteAuthor = "", quoteAuthorSign = "", quoteImage = "";
            bool   seSubio = false;
            int    quoteId = 0;

            foreach (string file in httpRequest.Files)
            {
                var postedFile = httpRequest.Files[file];
                var valid      = Utils.IsValidImage(postedFile, all);

                if (valid.Value == "Ok")
                {
                    if (postedFile != null)
                    {
                        var fil          = $"{Path.GetFileNameWithoutExtension(postedFile.FileName)}_{DateTime.Now.Ticks}{postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'))}";
                        var fileSavePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles"), fil);
                        if (!postedFile.FileName.StartsWith("/"))
                        {
                            postedFile.SaveAs(fileSavePath);
                            seSubio = true;
                            switch (file)
                            {
                            case "QuoteAuthorPhoto":
                                quoteImage = $"{"~/UploadedFiles"}/{fil}";
                                break;
                            }
                        }
                    }
                }
                else
                {
                    return(Json(new AjaxResponse {
                        Success = false, Message = valid.Value
                    }, JsonRequestBehavior.AllowGet));
                }
            }

            foreach (var form in httpRequest.Form.AllKeys)
            {
                var formValue = httpRequest.Form[form];
                formValue = string.IsNullOrEmpty(formValue) ? null : formValue;
                switch (form)
                {
                case "QuoteText":
                    quoteText = formValue;
                    break;

                case "QuoteAuthor":
                    quoteAuthor = formValue;
                    break;

                case "QuoteAuthorSign":
                    quoteAuthorSign = formValue;
                    break;

                case "QuoteId":
                    quoteId = Convert.ToInt32(formValue);
                    break;
                }
            }

            if (seSubio)
            {
                if (!string.IsNullOrEmpty(quoteText) && !string.IsNullOrEmpty(quoteAuthor))
                {
                    if (quoteId == 0)
                    {
                        db.Quotes.Add(new Quote
                        {
                            QuoteAuthorPhoto = quoteImage,
                            QuoteText        = quoteText,
                            QuoteAuthor      = quoteAuthor,
                            QuoteAuthorSign  = quoteAuthorSign
                        });
                    }
                    else
                    {
                        Quote quote = await db.Quotes.FindAsync(quoteId);

                        if (quote != null)
                        {
                            quote.QuoteAuthorPhoto = quoteImage;
                            quote.QuoteText        = quoteText;
                            quote.QuoteAuthor      = quoteAuthor;
                            quote.QuoteAuthorSign  = quoteAuthorSign;
                            db.Entry(quote).State  = EntityState.Modified;
                        }
                    }
                    await db.SaveChangesAsync();
                }

                return(Json(new AjaxResponse {
                    Success = true, Message = "Los datos fueron subidos correctamente al servidor"
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new AjaxResponse {
                Success = false, Message = "Ocurrió un error al subir lo(s) archivo(s)."
            }, JsonRequestBehavior.AllowGet));
        }