public void DeleteCandidature(int id)
        {
            candidature c = utwk.CandidatureRepository.GetById(id);

            utwk.CandidatureRepository.Delete(c);
            utwk.Commit();
        }
示例#2
0
        public ActionResult Approuvez(int id)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            candidature can = cand.GetById(id);

            if (can.status.Equals("non"))
            {
                can.status = "oui";
            }
            else
            {
                can.status = "non";
            }
            cand.Update(can);
            cand.Commit();
            return(RedirectToAction("Index"));
        }
示例#3
0
        // GET: Candidature/Delete/5
        public ActionResult Delete(int id)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(xc => xc.Type == ClaimTypes.Role)
                    .Select(xc => xc.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            candidature c = new candidature();

            c = cand.GetById(id);
            cand.Delete(c);
            cand.Commit();
            return(RedirectToAction("Index"));
        }
示例#4
0
        static void Main(string[] args)
        {
            easymissionEntities ctx = new easymissionEntities();
            candidature         c   = new candidature();

            c.status = "bara nayek";
            ctx.candidatures.Add(c);
            ctx.SaveChanges();
        }
        public ActionResult Delete(int id, candidature c)
        {
            try
            {
                // TODO: Add delete logic here

                s.DeleteCandidature(id);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#6
0
        public ActionResult Details(int id, OffreModel offremodel)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }

            candidature candid = new candidature();

            candid.description = offremodel.candidature.description;
            candid.idUser      = User.Identity.GetUserId();
            candid.idOffre     = id;
            candid.dateSubmit  = DateTime.Now;
            candid.status      = "non";
            var file = Request.Files[0];

            if (file != null && file.ContentLength > 0)
            {
                var    fileName = Path.GetFileName(file.FileName);
                var    path     = Path.Combine(Server.MapPath("~/Cvs/"), fileName);
                string x        = fileName;
                candid.cvPAth = x;
                file.SaveAs(path);
            }

            sC.Add(candid);
            sC.Commit();
            return(RedirectToAction("Index", "Service"));
        }
示例#7
0
        public ActionResult Edit(int id, candidature c)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(x => x.Type == ClaimTypes.Role)
                    .Select(x => x.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            candidature c1 = new candidature();

            c1             = cand.GetById(id);
            c1.description = c.description;
            c1.cvPAth      = c.cvPAth;
            c1.dateSubmit  = DateTime.Now;
            var file = Request.Files[0];

            if (file != null && file.ContentLength > 0)
            {
                var    fileName = Path.GetFileName(file.FileName);
                var    path     = Path.Combine(Server.MapPath("~/Cvs/"), fileName);
                string x        = fileName;
                c1.cvPAth = x;
                file.SaveAs(path);
            }
            cand.Update(c1);
            cand.Commit();
            return(RedirectToAction("Index"));
        }
 public void AddCandidature(candidature a)
 {
     utwk.CandidatureRepository.Add(a);
     utwk.Commit();
 }
        public ActionResult Create(CandidatureViewModel cvm, HttpPostedFileBase cv)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    RedirectToAction("Create");
                }
                //***********************Upload**************//
                UserCredential credential;

                using (var stream =
                           new FileStream("client_secret_871887422935-6o2u9sh6562ddakm77t7vcbkecrarhf2.apps.googleusercontent.com (1).json", FileMode.Open, FileAccess.Read))
                {
                    string credPath = System.Environment.GetFolderPath(
                        System.Environment.SpecialFolder.Personal);
                    credPath = Path.Combine(credPath, ".credentials/PiDrive");

                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets,
                        Scopes,
                        "user",
                        CancellationToken.None,
                        new FileDataStore(credPath, true)).Result;
                }

                // Create Drive API service.
                var service = new DriveService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName       = ApplicationName,
                });

                // Define parameters of request.
                FilesResource.ListRequest listRequest = service.Files.List();

                // List files.
                IList <Google.Apis.Drive.v2.Data.File> files = listRequest.Execute().Items;

                //**************

                Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
                body.Title       = cv.FileName;
                body.Description = "A test document";
                body.MimeType    = "application/pdf";

                var path = Path.Combine(Server.MapPath("~/Content/Upload/"), cv.FileName);
                cv.SaveAs(path);
                byte[]       byteArray = System.IO.File.ReadAllBytes(path);
                MemoryStream stream2;

                stream2 = new System.IO.MemoryStream(byteArray);


                request = service.Files.Insert(body, stream2, "application/pdf");

                request.Upload();


                Google.Apis.Drive.v2.Data.File file = request.Body;

                // TODO: Add insert logic here
                candidature obj = new candidature
                {
                    CandidateName = cvm.CandidateName,

                    urlCv        = request.ResponseBody.DownloadUrl,
                    dateCreation = (DateTime)request.ResponseBody.CreatedDate,
                    ifFile       = request.ResponseBody.Id
                };


                s.AddCandidature(obj);

                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
                return(View());
            }
        }