Ejemplo n.º 1
0
        public ActionResult Create(Pergunta pergunta, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                //pergunta.TipoResposta.Add(ViewBag.TipoResposta);
                db.Perguntas.Add(pergunta);

                //Cria uma lista do que foi passado no dorpdown
                var listaTipoRespostaRequest = form["TipoResposta"].Split(',').ToList();

                //Lista dos Tipo de resposta que existem no banco
                var listaTipoRespostaBd = db.TipoRespostas.ToList();

                //Para cada tipo de resposta enviada na pergunta, inseri na tabela perguntaTipoResposta
                foreach (var item in listaTipoRespostaRequest)
                {
                    //PEga objeto no db.TipoResposta que seja igual a item
                    var descTipoResposta = listaTipoRespostaBd.FirstOrDefault(f => f.DescricaoTipoResposta == item);

                    PerguntaTipoResposta perguntaTipoResposta = new PerguntaTipoResposta();
                    perguntaTipoResposta.IdPergunta     = pergunta.IdPergunta;
                    perguntaTipoResposta.IdtipoResposta = descTipoResposta.IdTipoResposta;

                    //Adiciona no banco
                    db.PerguntaTipoRespostas.Add(perguntaTipoResposta);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pergunta));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "IdPerfil,DescricaoPerfil,PerfilStatus")] Perfil perfil)
        {
            if (ModelState.IsValid)
            {
                db.Perfils.Add(perfil);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(perfil));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "IdTipoResposta,DescricaoTipoResposta,TipoRespostaStatus")] TipoResposta tipoResposta)
        {
            if (ModelState.IsValid)
            {
                db.TipoRespostas.Add(tipoResposta);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipoResposta));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "IdUsuario,Nome,Email,Telefone,IdPerfil,UsuarioStatus,Senha")] Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                db.Usuarios.Add(usuario);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdPerfil = new SelectList(db.Perfils.ToList().Where(x => x.PerfilStatus == true).Select(y => y.DescricaoPerfil));

            return(View(usuario));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "IdAvaliacao,DescricaoAvaliacao,Expiracao,Titulo,IdUsuario,IdPerfil,AvaliacaoStatus")] Avaliacao avaliacao)
        {
            if (ModelState.IsValid)
            {
                db.Avaliacaos.Add(avaliacao);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Perguntas = new SelectList(db.Perguntas.ToList().Where(f => f.PerguntaStatus == true).Select(g => g.DescricaoPergunta));
            ViewBag.IdPerfil  = new SelectList(db.Perfils.ToList().Where(f => f.PerfilStatus == true).Select(g => g.DescricaoPerfil));
            ViewBag.IdUsuario = new SelectList(db.Usuarios.ToList().Where(f => f.UsuarioStatus == true).Select(g => g.Nome));

            return(View(avaliacao));
        }
Ejemplo n.º 6
0
        public HttpResponseMessage put(int id, REVIEW review)
        {
            try
            {
                using (ReviewEntities entities = new ReviewEntities())
                {
                    var entity = entities.REVIEW.FirstOrDefault(e => e.ReviewId == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Review doesnt exist"));
                    }
                    else
                    {
                        entity.Rating           = review.Rating;
                        entity.Comment          = review.Comment;
                        entity.GenerateReviewId = review.GenerateReviewId;
                        entity.EmployeeId       = review.EmployeeId;
                        entity.PerameterId      = review.PerameterId;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Ejemplo n.º 7
0
        public ActionResult Create(Organization organization)
        {
            ViewBag.Countries = new SelectList(context.Countries, "CountryId", "CountryName");
            ViewBag.States    = new SelectList(context.States, "StateId", "StateName");
            ViewBag.Cities    = new SelectList(context.Cities, "CityId", "CityName");
            organization.Role = "Admin";
            if (ModelState.IsValid)
            {
                context.Organizations.Add(organization);
                context.SaveChanges();
                TempData["CreateOrganization"] = "Organization Added Successfully";
                return(RedirectToAction("Edit", new { id = organization.Id }));
            }

            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult CreateReview(Review review)
        {
            int organizationId = (int)TempData["organizationId"];

            review.OrganizationId = organizationId;
            TempData.Keep("organizationId");

            if (ModelState.IsValid)
            {
                context.Reviews.Add(review);
                context.SaveChanges();
                TempData["CreateReview"] = "Review Added Successfully";
                return(RedirectToAction("Edit", "Review", new { id = review.Id }));
            }
            return(View());
        }
Ejemplo n.º 9
0
        public ActionResult SubmitReview(ReviewSubmission reviewSubmission)
        {
            TempData.Keep("employeeId");
            var assignedreviewId = Convert.ToInt64(TempData["assignedReviewId"]);
            var assignedreview   = context.AssignedReviewDetails.Single(d => d.Id == assignedreviewId);

            var employee = context.Employees.Single(x => x.Id == assignedreview.EmployeeId);

            reviewSubmission.EmployeeId     = assignedreview.EmployeeId;
            reviewSubmission.OrganizationId = employee.OrganizationId;
            reviewSubmission.ReviewId       = assignedreview.ReviewId;
            reviewSubmission.ReviewerId     = Convert.ToInt64(TempData["employeeId"]);

            if (ModelState.IsValid)
            {
                context.ReviewSubmissions.Add(reviewSubmission);
                context.SaveChanges();
                TempData["ReviewSubmittedMessage"] = "Submitted Successfully";

                return(RedirectToAction("DeleteSubmittedAssignedReview", new { id = assignedreviewId }));
            }
            return(View());
        }
Ejemplo n.º 10
0
        public ActionResult Create(Employee employee)
        {
            employee.OrganizationId = (int)TempData["organizationId"];


            employee.Role = "User";

            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);

                db.SaveChanges();
                TempData["CreateMessage"] = "Employee Added Successfully";
                return(RedirectToAction("Edit", "Employees", new { id = employee.Id }));
            }

            ViewBag.CityId         = new SelectList(db.Cities, "CityId", "CityName", employee.CityId);
            ViewBag.CountryId      = new SelectList(db.Countries, "CountryId", "CountryName", employee.CountryId);
            ViewBag.EmployeeTypeId = new SelectList(db.EmployeeTypes, "Id", "EmployeeType1", employee.EmployeeTypeId);
            ViewBag.GenderId       = new SelectList(db.Genders, "Id", "Gender1", employee.GenderId);

            ViewBag.StateId = new SelectList(db.States, "StateId", "StateName", employee.StateId);
            return(View(employee));
        }
Ejemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         Guid id = Guid.NewGuid();
         model.Id        = id;
         model.FirstName = fname.Text;
         model.LastName  = lname.Text;
         model.Review    = comments.InnerText;
         model.Date      = DateTime.Now;
         using (ReviewEntities db = new ReviewEntities())
         {
             db.Master_Table.Add(model);
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 12
0
 public HttpResponseMessage post([FromBody] REVIEW review)
 {
     try
     {
         using (ReviewEntities entities = new ReviewEntities())
         {
             entities.REVIEW.Add(review);
             entities.SaveChanges();
             HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, review);
             message.Headers.Location = new Uri(Request.RequestUri + review.ReviewId.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Ejemplo n.º 13
0
 public HttpResponseMessage delete(int id)
 {
     try
     {
         using (ReviewEntities entities = new ReviewEntities())
         {
             var entity = entities.REVIEW.FirstOrDefault(e => e.ReviewId == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Review doesnt exist"));
             }
             else
             {
                 entities.REVIEW.Remove(entity);
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }