Exemple #1
0
        public ActionResult Update(Jop jop)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new JopFormsViewModel
                {
                    jop         = jop,
                    Locations   = db.Locations.ToList(),
                    Careers     = db.Careers.ToList(),
                    Experiences = db.Experiences.ToList()
                };
                return(View("EditJop", viewModel));
            }

            var jopInForm = db.Jops.Single(j => j.Id == jop.Id);

            jopInForm.Title        = jop.Title;
            jopInForm.CompanyName  = jop.CompanyName;
            jopInForm.Email        = jop.Email;
            jopInForm.Watsapp      = jop.Watsapp;
            jopInForm.Salary       = jop.Salary;
            jopInForm.CareerId     = jop.CareerId;
            jopInForm.LocationId   = jop.LocationId;
            jopInForm.ExperienceId = jop.ExperienceId;
            jopInForm.JopType      = jop.JopType;
            jopInForm.Details      = jop.Details;
            jopInForm.LastUpdated  = DateTime.Now;

            db.SaveChanges();

            return(RedirectToAction("JopIn", "Home"));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, Jop jop)
        {
            if (id != jop.Id)
            {
                ViewBag.ErrorMessage = "لايوجد   بيانات";
                return(View("NotFound"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update <Jop>(jop);
                    await _repository.SavaAll();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (_repository.GetSeason(jop.Id) == null)
                    {
                        ViewBag.ErrorMessage = "لايوجد   بيانات";
                        return(View("NotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(jop));
        }
        public ActionResult Edit(Jop jop, HttpPostedFileBase file)
        {
            if (file != null)
            {
                string oldpath    = Path.GetFileNameWithoutExtension(file.FileName);
                string extension1 = Path.GetExtension(file.FileName);
                oldpath    = oldpath + DateTime.Now.ToString("yymmssfff") + extension1;
                jop.jopImg = "~/files/" + oldpath;
                oldpath    = Path.Combine(Server.MapPath("~/files/"), oldpath);
                System.IO.File.Delete(oldpath);
                string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                string extension = Path.GetExtension(file.FileName);
                fileName   = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                jop.jopImg = "~/files/" + fileName;
                fileName   = Path.Combine(Server.MapPath("~/files/"), fileName);
                file.SaveAs(fileName);
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    db.Entry(jop).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                db.Entry(jop).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", jop.CategoryId);
            return(View(jop));
        }
Exemple #4
0
 public ActionResult Create(Jop jop)
 {
     jop.AnnouncedDate = DateTime.Now;
     db.Jops.Add(jop);
     db.SaveChanges();
     return(RedirectToAction("JopIn", "Home"));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Jop jop = db.Jops.Find(id);

            db.Jops.Remove(jop);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Jop jop = await db.Jops.FindAsync(id);

            db.Jops.Remove(jop);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public async Task <IActionResult> Create(Jop jop)
        {
            if (ModelState.IsValid)
            {
                _repository.Add <Jop>(jop);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jop));
        }
Exemple #8
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,JopTitle,JopDescription,CategoryId")] Jop jop)
        {
            if (ModelState.IsValid)
            {
                db.Entry(jop).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", jop.CategoryId);
            return(View(jop));
        }
        // GET: Jops/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jop jop = db.Jops.Find(id);

            if (jop == null)
            {
                return(HttpNotFound());
            }
            return(View(jop));
        }
Exemple #10
0
        public async Task <ActionResult> Create([Bind(Include = "Id,JopTitle,JopDescription,CategoryId")] Jop jop)
        {
            if (ModelState.IsValid)
            {
                db.Jops.Add(jop);
                jop.UserId = User.Identity.GetUserId();
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", jop.CategoryId);
            return(View(jop));
        }
Exemple #11
0
        // GET: Jops/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jop jop = await db.Jops.FindAsync(id);

            if (jop == null)
            {
                return(HttpNotFound());
            }
            return(View(jop));
        }
        // GET: Jops/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jop jop = db.Jops.Find(id);

            if (jop == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", jop.CategoryId);
            return(View(jop));
        }
Exemple #13
0
        public ActionResult Create(Jop jop, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                string path = Path.Combine(Server.MapPath("~/Uploads"), img.FileName);


                img.SaveAs(path);

                jop.image  = img.FileName;
                jop.UserID = User.Identity.GetUserId();
                db.Jops.Add(jop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", jop.CategoryId);
            return(View(jop));
        }
        public ActionResult Create(Jop jop, HttpPostedFileBase file)
        {
            string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
            string extension = Path.GetExtension(file.FileName);

            fileName   = fileName + DateTime.Now.ToString("yymmssfff") + extension;
            jop.jopImg = "~/files/" + fileName;
            fileName   = Path.Combine(Server.MapPath("~/files/"), fileName);
            file.SaveAs(fileName);

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                jop.UserId = User.Identity.GetUserId();
                db.Jops.Add(jop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ModelState.Clear();

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", jop.CategoryId);
            return(View(jop));
        }
Exemple #15
0
        public ActionResult Edit(Jop jop, HttpPostedFileBase img)
        {
            string oldpath = Path.Combine(Server.MapPath("~/Uploads"), jop.image);

            if (ModelState.IsValid)
            {
                if (img != null)
                {
                    System.IO.File.Delete(oldpath);
                    // string path = Path.Combine(Server.MapPath("~/Uploads"), img.FileName);
                    string filenames  = Path.GetFileNameWithoutExtension(img.FileName);
                    string extins     = Path.GetExtension(img.FileName);
                    string ReNameFile = filenames + DateTime.Now.ToString("yymmssff") + extins;
                    string path       = Path.Combine(Server.MapPath("~/Uploads"), ReNameFile);
                    img.SaveAs(path);
                    jop.image = ReNameFile;
                }
                db.Entry(jop).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", jop.CategoryId);
            return(View(jop));
        }