Beispiel #1
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description,Salary,Type,Country")] Carrer carrer)
 {
     if (ModelState.IsValid)
     {
         if (Session["Skills"] != null)
         {
             List <Skill> List = Session["Skills"] as List <Skill>;
             foreach (var item in List)
             {
                 item.Carrer_ID = carrer.ID;
                 db.Skills.Add(item);
             }
         }
         if (Session["Requirment"] != null)
         {
             List <Requirment> List = Session["Requirment"] as List <Requirment>;
             foreach (var item in List)
             {
                 item.Carrer_ID = carrer.ID;
                 db.Requirments.Add(item);
             }
         }
         db.Entry(carrer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carrer));
 }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Carrer carrer = db.Carrers.Find(id);

            db.Carrers.Remove(carrer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult DeleteRequirment(int id)
        {
            Requirment requirment = db.Requirments.Find(id);
            Carrer     carrer     = db.Carrers.Find(requirment.Carrer_ID);

            db.Requirments.Remove(requirment);
            db.SaveChanges();
            return(PartialView("_DeleteRequirment", carrer));
        }
Beispiel #4
0
        public ActionResult DeleteSkill(int id)
        {
            Skill  skill  = db.Skills.Find(id);
            Carrer carrer = db.Carrers.Find(skill.Carrer_ID);

            db.Skills.Remove(skill);
            db.SaveChanges();
            return(PartialView("_DeleteSkills", carrer));
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Trace.WriteLine("POST /Carrer/Delete/" + id);
            Carrer carrer = db.CarrerM.Find(id);

            db.CarrerM.Remove(carrer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "id,Description,CreatedDate")] Carrer carrer)
 {
     Trace.WriteLine("POST /Carrer/Edit/" + carrer.id);
     if (ModelState.IsValid)
     {
         db.Entry(carrer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carrer));
 }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "Description,CreatedDate")] Carrer carrer)
        {
            Trace.WriteLine("POST /Carrer/Create");
            if (ModelState.IsValid)
            {
                db.CarrerM.Add(carrer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(carrer));
        }
Beispiel #8
0
        // GET: Carrers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            Carrer carrer = db.Carrers.Find(id);

            if (carrer == null)
            {
                return(HttpNotFound());
            }
            return(View(carrer));
        }
Beispiel #9
0
        // GET: Carrer/Edit/5
        public ActionResult Edit(int?id)
        {
            Trace.WriteLine("GET /Carrer/Edit/" + id);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Carrer carrer = db.CarrerM.Find(id);

            if (carrer == null)
            {
                return(HttpNotFound());
            }
            return(View(carrer));
        }
Beispiel #10
0
        // GET: Carrers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            Carrer carrer = db.Carrers.Find(id);

            if (carrer == null)
            {
                return(HttpNotFound());
            }
            if (Session["Skills"] != null)
            {
                Session.Remove("Skills");
            }
            if (Session["Requirment"] != null)
            {
                Session.Remove("Requirment");
            }
            return(View(carrer));
        }
        public ActionResult SubmitCV(Carrer c, HttpPostedFileBase file)
        {
            if (file == null)
            {
                ModelState.AddModelError("CustomError", "Please select CV");
                return(View());
            }

            if (!(file.ContentType == "application/vnd.openxmlformats-officedocument." ||
                  file.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Only .docx and .pdf file allowed ");
                return(View());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);

                    string path = Server.MapPath("~/UploadedCV");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    file.SaveAs(Path.Combine(path, fileName));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("CustomError", ex);
                }
            }

            return(View());
        }
Beispiel #12
0
        public ActionResult SubmitCV(Carrer c, HttpPostedFileBase file)
        {
            if (file == null)
            {
                ModelState.AddModelError("CustomError", "Please select cv");

                return(View());
            }
            if (!(file.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
                  file.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Only .docx and .pdf file allowed");
                return(View());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    //string fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                    //file.SaveAs(System.IO.Path.Combine(Server.MapPath("~/UploadedCV"), fileName));
                    using (MyDatabaseEntities dc = new MyDatabaseEntities())
                    {
                        // c.CV = fileName;
                        dc.Carrers.Add(c);
                        dc.SaveChanges();
                    }
                    ModelState.Clear();
                    c = null;
                    ViewBag.Message = "Successfully Done";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "Error! Please try again";
                    return(View());
                }
            }
            return(View());
        }
Beispiel #13
0
 public ActionResult Create([Bind(Include = "ID,Name,Description,Salary,Type,Country")] Carrer carrer)
 {
     if (Session["Skills"] != null)
     {
         List <Skill> List = Session["Skills"] as List <Skill>;
         foreach (var item in List)
         {
             carrer.Skills.Add(item);
         }
         Session.Remove("Skills");
     }
     if (Session["Requirment"] != null)
     {
         List <Requirment> List = Session["Requirment"] as List <Requirment>;
         foreach (var item in List)
         {
             carrer.Requirments.Add(item);
         }
         Session.Remove("Requirment");
     }
     db.Carrers.Add(carrer);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }