private void AddClient()
        {
            ManagerValidation VM = new ManagerValidation();
            bool correctForm     = VM.ClientValidation(FirstName, LastName, CompanyName, NIP, REGON);

            if (correctForm)
            {
                Client client;

                client = AddClientObject();

                dbContext.Client.Add(client);
                dbContext.SaveChanges();


                _FilteredClients = new ObservableCollection <Client>(dbContext.Client);
                _Clients         = new ObservableCollection <Client>(dbContext.Client);

                RaisePropertyChanged("FilteredClients");
                RaisePropertyChanged("Clients");

                clear();

                ErrorMessage er = new ErrorMessage("Client created successfully!");
                er.ShowDialog();
            }
        }
Example #2
0
        private void AddArticle()
        {
            AdminValidation VM          = new AdminValidation();
            bool            correctForm = VM.WikiValidation(Url, Description);

            if (correctForm)
            {
                Article article = new Article()
                {
                    Url         = _Url,
                    Description = _Description,
                    DateAdded   = DateTime.Now,
                    UserID      = Global.user.UserID
                };

                dbContext.Article.Add(article);
                dbContext.SaveChanges();

                Articles = new ObservableCollection <Article>(dbContext.Article);

                setVariableWhenAddArticle();
                ErrorMessage er = new ErrorMessage("Add article!");
                er.ShowDialog();
            }
        }
Example #3
0
        public ActionResult Create([Bind(Include = "PrestadoraServicoId,RazaoSocial,Cnpj,Telefone,Email")] PrestadoraServico prestadoraServico)
        {
            if (ModelState.IsValid)
            {
                db.PrestadoraServicoes.Add(prestadoraServico);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(prestadoraServico));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "ID,Descricao,Preco,UltimaCompra,Estoque")] Produto produto)
        {
            if (ModelState.IsValid)
            {
                db.Produtoes.Add(produto);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(produto));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "QualificationId,QualificationName")] Qualification qualification)
        {
            if (ModelState.IsValid)
            {
                db.Qualifications.Add(qualification);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(qualification));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "TipoOcorrenciaPBId,Tipo,Observacao")] TipoOcorrenciaPB tipoOcorrenciaPB)
        {
            if (ModelState.IsValid)
            {
                db.TipoOcorrenciaPBs.Add(tipoOcorrenciaPB);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipoOcorrenciaPB));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "StatusOcorrenciaSecId,Status,Observacao")] StatusOcorrenciaSec statusOcorrenciaSec)
        {
            if (ModelState.IsValid)
            {
                db.StatusOcorrenciaSecs.Add(statusOcorrenciaSec);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(statusOcorrenciaSec));
        }
Example #8
0
        public ActionResult Create([Bind(Include = "SecretariaId,Nome,Setor,Observacao")] Secretaria secretaria)
        {
            if (ModelState.IsValid)
            {
                db.Secretarias.Add(secretaria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(secretaria));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "PrefeituraBairroId,Codigo,Nome,Endereco,Referencia,Cep,Email,Tel1,Tel2,Gestor")] PrefeituraBairro prefeituraBairro)
        {
            if (ModelState.IsValid)
            {
                db.PrefeituraBairroes.Add(prefeituraBairro);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(prefeituraBairro));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "OcorrenciaId,Numero,Descricao")] Ocorrencia ocorrencia)
        {
            if (ModelState.IsValid)
            {
                db.Ocorrencias.Add(ocorrencia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ocorrencia));
        }
Example #11
0
        public ActionResult Create([Bind(Include = "EmployeeTypeId,EmployeeTypeName")] EmployeeType employeetype)
        {
            if (ModelState.IsValid)
            {
                db.EmployeeTypes.Add(employeetype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeetype));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "CrimeId,CrimeName")] Crime crime)
        {
            if (ModelState.IsValid)
            {
                db.Crime.Add(crime);
                db.SaveChanges();
                return(RedirectToAction("Index", "Role"));
            }

            return(View(crime));
        }
Example #13
0
        public ActionResult Create([Bind(Include = "TrainingTypeId,TrainingTypeName")] TrainingType trainingtype)
        {
            if (ModelState.IsValid)
            {
                db.TrainingTypes.Add(trainingtype);
                db.SaveChanges();
                return(RedirectToAction("Index", "Role"));
            }

            return(View(trainingtype));
        }
Example #14
0
        public ActionResult Create([Bind(Include = "TipoCargoId,Nome")] TipoCargo tipoCargo)
        {
            if (ModelState.IsValid)
            {
                db.TipoCargoes.Add(tipoCargo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipoCargo));
        }
Example #15
0
        public ActionResult Create([Bind(Include = "DescricaoOcorrenciaEscolaId,Descricao,Observacao")] DescricaoOcorrenciaEscola descricaoOcorrenciaEscola)
        {
            if (ModelState.IsValid)
            {
                db.DescricaoOcorrenciaEscolas.Add(descricaoOcorrenciaEscola);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(descricaoOcorrenciaEscola));
        }
Example #16
0
        public ActionResult Create([Bind(Include = "EscolaId,Codigo,Nome,Tel1,Tel2,Cep,Bairro,Logradouro,Numero,Latitude,Longitude,Gestor,GreId")] Escola escola)
        {
            if (ModelState.IsValid)
            {
                db.Escolas.Add(escola);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GreId = new SelectList(db.Gres, "GreId", "Regional", escola.GreId);
            return(View(escola));
        }
Example #17
0
        public ActionResult Create([Bind(Include = "GreId,Regional,Codigo,Endereco,Referencia,Cep,Email,Tel1,Tel2,Gestor,SecretariaId")] Gre gre)
        {
            if (ModelState.IsValid)
            {
                db.Gres.Add(gre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SecretariaId = new SelectList(db.Secretarias, "SecretariaId", "Nome", gre.SecretariaId);
            return(View(gre));
        }
Example #18
0
        public ActionResult Create([Bind(Include = "CargoId,Nome,Descricao,TipoCargoId")] Cargo cargo)
        {
            if (ModelState.IsValid)
            {
                db.Cargoes.Add(cargo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TipoCargoId = new SelectList(db.TipoCargoes, "TipoCargoId", "Nome", cargo.TipoCargoId);
            return(View(cargo));
        }
Example #19
0
        public ActionResult Create([Bind(Include = "HistoricoStatusOcorrenciaSecId,Data,Observacao,StatusOcorrenciaSecId,OcorrenciaSecId")] HistoricoStatusOcorrenciaSec historicoStatusOcorrenciaSec)
        {
            if (ModelState.IsValid)
            {
                db.HistoricoStatusOcorrenciaSecs.Add(historicoStatusOcorrenciaSec);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OcorrenciaSecId       = new SelectList(db.OcorrenciaSecs, "OcorrenciaSecId", "latitude", historicoStatusOcorrenciaSec.OcorrenciaSecId);
            ViewBag.StatusOcorrenciaSecId = new SelectList(db.StatusOcorrenciaSecs, "StatusOcorrenciaSecId", "Status", historicoStatusOcorrenciaSec.StatusOcorrenciaSecId);
            return(View(historicoStatusOcorrenciaSec));
        }
Example #20
0
        /*private void RemoveTeam(object ID)
         * {
         *
         *
         *  int val = Convert.ToInt32(ID);
         *  Team team = dbContext.Team.Find(val);
         *  AdminValidation AV = new AdminValidation();
         *  bool correctForm = AV.RemoveTeamValidation(team);
         *  if (correctForm)
         *  {
         *      dbContext.Team.Remove(team);
         *      dbContext.SaveChanges();
         *  }
         * }*/

        #endregion

        #region helpMethods

        private void addTeam()
        {
            Team team = new Team
            {
                Name             = Name,
                NumberOfPeople   = UserInNewTeam.Count(),
                NumberOfProjects = 0,
                Users            = UserInNewTeam
            };

            dbContext.Team.Add(team);
            dbContext.SaveChanges();
        }
Example #21
0
        public ActionResult Create([Bind(Include = "TerceirizadoId,Nome,Cpf,DataAdmissao,Telefone,PrestadoraServicoId,CargoId,OcorrenciaId")] Terceirizado terceirizado)
        {
            if (ModelState.IsValid)
            {
                db.Terceirizadoes.Add(terceirizado);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CargoId             = new SelectList(db.Cargoes, "CargoId", "Nome", terceirizado.CargoId);
            ViewBag.OcorrenciaId        = new SelectList(db.Ocorrencias, "OcorrenciaId", "Descricao", terceirizado.OcorrenciaId);
            ViewBag.PrestadoraServicoId = new SelectList(db.PrestadoraServicoes, "PrestadoraServicoId", "RazaoSocial", terceirizado.PrestadoraServicoId);
            return(View(terceirizado));
        }
Example #22
0
        public ActionResult Create([Bind(Include = "OcorrenciaSecId,latitude,longitude,logradouro,numero,bairro,cep,cidade,estado,Data,TipoOcorrenciaSecId,DescricaoOcorrenciaSecId,SecretariaId")] OcorrenciaSec ocorrenciaSec)
        {
            if (ModelState.IsValid)
            {
                ocorrenciaSec.Data = DateTime.Now;
                db.OcorrenciaSecs.Add(ocorrenciaSec);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DescricaoOcorrenciaSecId = new SelectList(db.DescricaoOcorrenciaSecs, "DescricaoOcorrenciaSecId", "Descricao", ocorrenciaSec.DescricaoOcorrenciaSecId);
            ViewBag.SecretariaId             = new SelectList(db.Secretarias, "SecretariaId", "Nome", ocorrenciaSec.SecretariaId);
            ViewBag.TipoOcorrenciaSecId      = new SelectList(db.TipoOcorrenciaSecs, "TipoOcorrenciaSecId", "Tipo", ocorrenciaSec.TipoOcorrenciaSecId);
            return(View(ocorrenciaSec));
        }
Example #23
0
        public ActionResult Create([Bind(Include = "OcorrenciaPBId,latitude,longitude,logradouro,numero,bairro,cep,cidade,estado,Data,TipoOcorrenciaPBId,DescricaoOcorrenciaPBId,PrefeituraBairroId")] OcorrenciaPB ocorrenciaPB)
        {
            if (ModelState.IsValid)
            {
                ocorrenciaPB.Data = DateTime.Now;
                db.OcorrenciaPBs.Add(ocorrenciaPB);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DescricaoOcorrenciaPBId = new SelectList(db.DescricaoOcorrenciaPBs, "DescricaoOcorrenciaPBId", "Descricao", ocorrenciaPB.DescricaoOcorrenciaPBId);
            ViewBag.PrefeituraBairroId      = new SelectList(db.PrefeituraBairroes, "PrefeituraBairroId", "Nome", ocorrenciaPB.PrefeituraBairroId);
            ViewBag.TipoOcorrenciaPBId      = new SelectList(db.TipoOcorrenciaPBs, "TipoOcorrenciaPBId", "Tipo", ocorrenciaPB.TipoOcorrenciaPBId);
            return(View(ocorrenciaPB));
        }
Example #24
0
        public ActionResult Create([Bind(Include = "OcorrenciaGreId,latitude,longitude,logradouro,numero,bairro,cep,cidade,estado,Data,TipoOcorrenciaGreId,DescricaoOcorrenciaGreId,GreId")] OcorrenciaGre ocorrenciaGre)
        {
            if (ModelState.IsValid)
            {
                ocorrenciaGre.Data = DateTime.Now;
                db.OcorrenciaGres.Add(ocorrenciaGre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DescricaoOcorrenciaGreId = new SelectList(db.DescricaoOcorrenciaGres, "DescricaoOcorrenciaGreId", "Descricao", ocorrenciaGre.DescricaoOcorrenciaGreId);
            ViewBag.GreId = new SelectList(db.Gres, "GreId", "Regional", ocorrenciaGre.GreId);
            ViewBag.TipoOcorrenciaGreId = new SelectList(db.TipoOcorrenciaGres, "TipoOcorrenciaGreId", "Tipo", ocorrenciaGre.TipoOcorrenciaGreId);
            return(View(ocorrenciaGre));
        }
Example #25
0
        public ActionResult Create([Bind(Include = "CaseId,CaseName,CaseDate,PrisonerId,JudgeName,CourtName,CaseDescription,Scheduled,EmployeeId")] Case @case)
        {
            if (ModelState.IsValid)
            {
                int id = (int)(_context.Session["employee_Id"]);
                @case.EmployeeId = id;
                @case.Scheduled  = true;
                db.Cases.Add(@case);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.PrisonerId = new SelectList(db.Prisoners, "PrisonerId", "PrisonerRegNo", @case.Prisoner.PrisonerRegNo);
            return(View(@case));
        }
Example #26
0
        private void EditClient()
        {
            AdminValidation VM          = new AdminValidation();
            bool            correctForm = VM.ClientValidation(FirstName, LastName, CompanyName, NIP, REGON);

            if (correctForm)
            {
                MySelectedClient.FirstName = FirstName;
                MySelectedClient.LastName  = LastName;

                MySelectedClient.CompanyName = CompanyName;

                MySelectedClient.NIP             = NIP;
                MySelectedClient.REGON           = REGON;
                MySelectedClient.Street          = Street;
                MySelectedClient.HouseNumber     = HouseNumber;
                MySelectedClient.ApartmentNumber = ApartmentNumber;
                MySelectedClient.Postcode        = Postcode;
                MySelectedClient.City            = City;

                dbContext.SaveChanges();

                Clients = new ObservableCollection <Client>(dbContext.Client);

                setVariable();

                ErrorMessage er = new ErrorMessage("Client edit successfully!");
                er.ShowDialog();
            }
        }
Example #27
0
        public ActionResult Create([Bind(Include = "TrainingId,TrainingTypeId,Duration,Trained,PrisonerId,EmployeeId")] Training training)
        {
            if (ModelState.IsValid)
            {
                int id = (int)(_context.Session["employee_Id"]);
                training.EmployeeId = id;
                training.Trained    = true;
                db.Trainings.Add(training);
                db.SaveChanges();
                return(RedirectToAction("Success"));
            }

            //ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "FirstName", training.EmployeeId);
            ViewBag.PrisonerId     = new SelectList(db.Prisoners, "PrisonerId", "PrisonerRegNo", training.PrisonerId);
            ViewBag.TrainingTypeId = new SelectList(db.TrainingTypes, "TrainingTypeId", "TrainingTypeName", training.TrainingTypeId);
            return(View(training));
        }
Example #28
0
        public bool SaveAccommodationPackage(AccommodationPackage accommodationPackage)
        {
            var context = new PMSContext();

            context.AccommodationPackages.Add(accommodationPackage);

            return(context.SaveChanges() > 0);
        }
        public bool UpdateAccommodation(Accommodation accommodation)
        {
            var context = new PMSContext();

            context.Entry(accommodation).State = System.Data.Entity.EntityState.Modified;

            return(context.SaveChanges() > 0);
        }
Example #30
0
        public bool DeleteAccommodationType(AccommodationType accommodationType)
        {
            var context = new PMSContext();

            context.Entry(accommodationType).State = System.Data.Entity.EntityState.Deleted;

            return(context.SaveChanges() > 0);
        }