コード例 #1
0
        public async Task <ActionResult> Create(Apt apt)
        {
            if (ModelState.IsValid)
            {
                var aptSolo = await db.AptSolo.FindAsync(int.Parse(apt.AptsIdentificador));

                apt.Foto1 = aptSolo.Foto1;
                apt.Foto2 = aptSolo.Foto2;
                apt.Foto3 = aptSolo.Foto3;
                db.Apt.Add(apt);


                aptSolo.Alugado         = true;
                db.Entry(aptSolo).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index1"));
            }

            ViewBag.PersonaID = new SelectList(db.Persona, "PersonaID", "Nombre", apt.PersonaID);
            return(View(apt));
        }
コード例 #2
0
        public async Task <ActionResult> Edit(int Id, string Nombre, string Rg, string Cpf, string Telefone, string Email)
        {
            var persona = new Persona();

            if (Nombre.Length > 0)
            {
                persona.PersonaID = Id;
                persona.Nombre    = Nombre;
                persona.Rg        = Int32.Parse(Rg);
                persona.Cpf       = Int64.Parse(Cpf);
                persona.Telefone  = Int32.Parse(Telefone);
                persona.Email     = Email;

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

                return(RedirectToAction("Index"));
            }
            return(View(persona));
        }
コード例 #3
0
        public async Task <ActionResult> Edit(int Id, string Descripcion, string Precio, HttpPostedFileBase Foto1, HttpPostedFileBase Foto2, HttpPostedFileBase Foto3)
        {
            var aptSolo = await db.AptSolo.FindAsync(Id);

            var apt = await db.Apt.FindAsync(Id.ToString());

            var folder = "~/Content/apt";

            if (Descripcion.Length > 0)
            {
                if (Foto1 != null)
                {
                    var pic1 = FileUpload.UploadFoto(Foto1, folder);
                    pic1          = string.Format("{0}/{1}", folder, pic1);
                    aptSolo.Foto1 = pic1;
                    if (apt != null)
                    {
                        apt.Foto1 = pic1;
                    }
                }

                if (Foto2 != null)
                {
                    var pic2 = FileUpload.UploadFoto(Foto2, folder);
                    pic2          = string.Format("{0}/{1}", folder, pic2);
                    aptSolo.Foto2 = pic2;
                    if (apt != null)
                    {
                        apt.Foto2 = pic2;
                    }
                }

                if (Foto3 != null)
                {
                    var pic3 = FileUpload.UploadFoto(Foto3, folder);
                    pic3          = string.Format("{0}/{1}", folder, pic3);
                    aptSolo.Foto3 = pic3;
                    if (apt != null)
                    {
                        apt.Foto3 = pic3;
                    }
                }
                aptSolo.AptSoloID   = Id;
                aptSolo.Descripcion = Descripcion;
                aptSolo.Precio      = Int32.Parse(Precio);

                if (apt != null)
                {
                    apt.Descripcion     = Descripcion;
                    apt.Precio          = Int32.Parse(Precio);
                    db.Entry(apt).State = EntityState.Modified;
                }

                db.Entry(aptSolo).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(aptSolo));
        }