public ActionResult Edit([Bind(Include = "Id,Nombre,Descripccion,FechaCreacion,FechaCierre,URLFoto,UsuarioId,Activa,Lugar")] Propuesta propuesta)
 {
     if (ModelState.IsValid)
     {
         db.Entry(propuesta).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UsuarioId = new SelectList(db.Usuarios, "Id", "Nombre", propuesta.UsuarioId);
     return(View(propuesta));
 }
        public ActionResult Edit([Bind(Include = "JobApplicationID,JobID,WorkerID,Motivation,Response")] JobApplication jobApplication)
        {
            JobApplication ja = db.JobApplications.Find(jobApplication.JobApplicationID);


            var id = jobApplication.JobApplicationID;

            var apps = db.JobApplications.Where(x => x.JobApplicationID != id).Where(x => x.JobID == jobApplication.JobID).Select(x => x.JobApplicationID);

            var appList = db.JobApplications.Where(j => j.JobID == jobApplication.JobID).Where(j => j.JobApplicationID != jobApplication.JobApplicationID);



            if (User.IsInRole("Worker"))
            {
                ja.Motivation = jobApplication.Motivation;
            }
            else if (User.IsInRole("Employer"))
            {
                ja.Response = jobApplication.Response;

                ja.Replied = true;
                if (jobApplication.Response == Reply.Hired)
                {
                    foreach (var item in apps)
                    {
                        JobApplication j = db.JobApplications.Find(item);
                        j.Response        = Reply.Rejected;
                        j.Replied         = true;
                        db.Entry(j).State = EntityState.Modified;
                    }
                }
            }

            if (ModelState.IsValid)
            {
                db.Entry(ja).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.JobAppID = db.JobApplications.Where(i => i.JobApplicationID == ja.JobApplicationID);
            ViewBag.JobID    = jobApplication.JobID;
            ViewBag.WorkerID = jobApplication.WorkerID;

            return(View(ja));
        }
Esempio n. 3
0
        public ActionResult ModificarUsuario(EditarUsuarioModel modelo)
        {
            if (ModelState.IsValid)
            {
                HttpPostedFileBase file     = modelo.File;
                Usuario            userInfo = modelo.MyUserInfo;

                if (userInfo.Fotos == null)
                {
                    userInfo.Fotos = new List <FotoPorfolio>();
                }


                if (file != null && file.ContentLength > 0)
                {
                    Guid   guid = Guid.NewGuid();
                    string str  = guid.ToString();

                    string path = Path.Combine(Server.MapPath("~/ProfilePictures"), str + ".jpg");

                    using (MemoryStream outStream = new MemoryStream())
                    {
                        using (ImageFactory imageFactory = new ImageFactory(preserveExifData: false))
                        {
                            Size size = new Size(200, 200);
                            ISupportedImageFormat format = new JpegFormat {
                                Quality = 80
                            };
                            imageFactory.Load(file.InputStream)
                            .Constrain(size)
                            .BackgroundColor(Color.White)
                            .Format(format)
                            .Save(path);
                        }
                    }

                    userInfo.URLFotoPerfil = str;
                }
                Usuario usuarioActual = ObtenerUsuarioActual(User);

                //copiar una por una las propiedades al usuario actual
                usuarioActual.Apellido      = userInfo.Apellido;
                usuarioActual.Descripcion   = userInfo.Descripcion;
                usuarioActual.Email         = userInfo.Descripcion;
                usuarioActual.Facebook      = userInfo.Facebook;
                usuarioActual.Instagram     = userInfo.Instagram;
                usuarioActual.Nombre        = userInfo.Nombre;
                usuarioActual.Rol           = userInfo.Rol;
                usuarioActual.Telefono      = userInfo.Telefono;
                usuarioActual.URLFotoPerfil = userInfo.URLFotoPerfil;
                usuarioActual.Website       = userInfo.Website;

                db.Entry(usuarioActual).State = EntityState.Modified;
                db.SaveChanges();

                return(View("Usuario", ObtenerUsuarioActual(User)));
            }
            return(View(modelo));
        }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "HelpID,HelpQuestion,HelpAnswer")] Help help)
 {
     if (ModelState.IsValid)
     {
         db.Entry(help).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(help));
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "NotificationID,Message,notice,Updated")] Notification notification)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notification).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(notification));
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "CityID,CityName,CityAbbrev")] City city)
 {
     if (ModelState.IsValid)
     {
         db.Entry(city).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(city));
 }
Esempio n. 7
0
 public ActionResult Edit([Bind(Include = "SuburbID,SubName,CityID")] Suburb suburb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(suburb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", suburb.CityID);
     return(View(suburb));
 }
Esempio n. 8
0
        public ActionResult Update([Bind(Include = "JobID,Completed,StartDate, EndDate, EndTime, StartTime, DateAdvertised, Title, Description, AddressLine1, Rate, SuburbID")] Job job)
        {
            Job a = db.Jobs.Find(job.JobID);

            a.Completed = job.Completed;


            if (ModelState.IsValid)
            {
                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.Job      = db.Jobs.Where(j => j.JobID == job.JobID);
            ViewBag.JobID    = job.JobID;
            ViewBag.SuburbID = new SelectList(db.Suburbs, job.SuburbID);
            return(View(a));
        }
Esempio n. 9
0
 public ActionResult Edit([Bind(Include = "ReviewID,Rating,Comment,ReportDate,JobApplicationID")] Review review)
 {
     if (ModelState.IsValid)
     {
         db.Entry(review).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.JobApplicationID = new SelectList(db.JobApplications, "JobApplicationID", "Motivation", review.JobID);
     return(View(review));
 }
Esempio n. 10
0
        public ActionResult Edit([Bind(Include = "EmployerID,WorkName,WorkNumber,WorkAddress1,WorkAddress2,SuburbID")] Employer employer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(employer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToRoute("Default", new { controller = "Manage", action = "Index" }));
            }

            ViewBag.SuburbID = new SelectList(db.Suburbs, "SuburbID", "SubName", employer.SuburbID);
            return(View(employer));
        }
Esempio n. 11
0
        public ActionResult Edit([Bind(Include = "SkillID,SkillDescription,Recom_Rate")] Skill skill)
        {
            Skill sk = db.Skills.Find(skill.SkillID);

            sk.Recom_Rate       = skill.Recom_Rate;
            sk.SkillDescription = skill.SkillDescription;
            if (ModelState.IsValid)
            {
                db.Entry(sk).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(skill));
        }
Esempio n. 12
0
        public ActionResult Edit([Bind(Exclude = "WorkerID", Include = "SkillID,YearsOfExperience")] WorkerSkill workerSkill)
        {
            workerSkill.WorkerID = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                db.Entry(workerSkill).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToRoute("Default", new { controller = "Manage", action = "Index" }));;
            }
            ViewBag.SkillID = new SelectList(db.Skills, "SkillID", "SkillDescription", workerSkill.SkillID);

            return(View(workerSkill));
        }
        public ActionResult Calificar(Calificacion modelo)
        {
            if (ModelState.IsValid)
            {
                Propuesta propuesta     = db.Propuestas.Find(modelo.PropuestaId);
                Usuario   usuarioActual = ObtenerUsuarioActual(User);

                //modelo.Propuesta = propuesta;
                //modelo.PropuestaId = propuesta.Id;

                db.Calificaciones.Add(modelo);
                db.SaveChanges();


                if (usuarioActual.Id == propuesta.Creador.Id)
                {
                    //soy el dueno
                    propuesta.CalificacionCreador   = modelo;
                    propuesta.CalificacionCreadorId = modelo.Id;
                }
                else if (usuarioActual.Id == propuesta.UsuarioGanador.Id)
                {
                    //soy el ganador
                    propuesta.CalificacionGanador   = modelo;
                    propuesta.CalificacionGanadorId = modelo.Id;
                }

                modelo.PropuestaId = propuesta.Id;

                db.Entry(propuesta).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 14
0
        public JsonResult Update(int incidentID, Prog progress)
        {
            Incident incident = db.Incidents.Find(incidentID);

            incident.Progress = progress;

            bool result = false;

            if (incident != null)
            {
                db.Entry(incident).State = EntityState.Modified;
                db.SaveChanges();
                result = true;
            }
            //ViewBag.JobApplicationID = new SelectList(db.JobApplications, "JobApplicationID", "Motivation", incident.JobApplicationID);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

            using (var db = new IdentityDb())
            {
                db.Database.Log = (c) => { System.Diagnostics.Debug.WriteLine(c); };

                foreach (var iclaim in userIdentity.Claims)
                {
                    if (acceptedClaims.Contains(iclaim.Type))
                    {
                        var usr = await manager.FindByIdAsync(this.Id);

                        var claim = usr.Claims.Where(c => c.ClaimType == iclaim.Type).FirstOrDefault();

                        if (claim == null)
                        {
                            usr.Claims
                            .Add(new UserClaimIntPk
                            {
                                ClaimType  = iclaim.Type,
                                ClaimValue = iclaim.Value,
                                UserId     = this.Id
                            });
                        }
                        else
                        {
                            if (claim.ClaimValue != iclaim.Value)
                            {
                                claim.ClaimValue      = iclaim.Value;
                                db.Entry(claim).State = System.Data.Entity.EntityState.Modified;
                            }
                        }
                    }
                }
                db.SaveChanges();
            }
            return(userIdentity);
        }
Esempio n. 16
0
        public async Task <ActionResult> CredentialsPost([Bind(Include = "Name,Id,Description")] RoleViewModel model, params int[] selectedCredentials)
        {
            if (model == null || selectedCredentials == null || selectedCredentials.Count() == 0) // BadRequest
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // Adiciona credenciais
            ApplicationRole entityRole = _db.ApplicationRoles.Include(c => c.Credentials).Where(r => r.Id == model.Id).Single();

            if (entityRole == null) // NotFound
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            foreach (int credId in selectedCredentials)
            {
                Credential credential = _db.Credentials.Where(c => c.Id == credId).Single();
                entityRole.Credentials.Add(credential);
            }
            _db.Entry(entityRole).State = EntityState.Modified;
            _db.SaveChanges();

            // Remove credenciais
            var role = await RoleManager.FindByIdAsync(model.Id);

            List <int> removedCredentials = role.Credentials.Select(c => c.Id).ToList().Except(selectedCredentials).ToList();

            foreach (int credId in removedCredentials)
            {
                Credential credential = role.Credentials.Where(c => c.Id == credId).Single();
                role.Credentials.Remove(credential);
            }

            TempData["Success"] = string.Format("Credenciais de {0} modificadas com sucesso.", model.Name);

            await RoleManager.UpdateAsync(role);

            return(View("Index", RoleManager.Roles.OrderBy(r => r.Name)));
        }
        public ActionResult Edit([Bind(Exclude = "CompanyBanner, Logo", Include = "ID,CompanyName,Slogan,Description, TelNo,FaxNo,SuburbID")] GeneralBusiness generalBusiness)
        {
            byte[] bannerData = null;

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase poImgFile = Request.Files["CompanyBanner"];
                var image = poImgFile;
                using (var binary = new BinaryReader(poImgFile.InputStream))
                {
                    bannerData = binary.ReadBytes(poImgFile.ContentLength);
                }
            }

            byte[] logoData = null;

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase poImgFile = Request.Files["Logo"];
                var image = poImgFile;
                using (var binary = new BinaryReader(poImgFile.InputStream))
                {
                    logoData = binary.ReadBytes(poImgFile.ContentLength);
                }
            }

            generalBusiness.Logo          = logoData;
            generalBusiness.CompanyBanner = bannerData;

            if (ModelState.IsValid)
            {
                db.Entry(generalBusiness).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(generalBusiness));
        }
Esempio n. 18
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ProductId)
            {
                return(BadRequest());
            }

            product.UserId          = currentUser.Id;
            db.Entry(product).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void UpdateCategory(Category category)
 {
     _context.Entry(category).State = EntityState.Modified;
     _context.SaveChanges();
 }
 public void UpdateProduct(Product product)
 {
     _context.Entry(product).State = EntityState.Modified;
     _context.SaveChanges();
 }