예제 #1
0
        public object AddPreviousEmployment(string id, PreviousEmployment previousemployment)
        {
            try
            {
                previousemployment.Employee_id = DatabaseAction.GetEmployeeID(id);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                db.PreviousEmployments.Add(previousemployment);
                db.SaveChanges();
                return(new Response
                {
                    Status = "Success",
                    Message = "Employee PreviousEmployments Details Successfully Added"
                });
            }

            catch (Exception ex)
            {
                LogFile.WriteLog(ex);
                return(BadRequest());
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PreviousEmployment previousEmployment = db.PreviousEmployment.Find(id);

            db.PreviousEmployment.Remove(previousEmployment);
            db.SaveChanges();
            TempData["msg"] = "<script>alert('This employment history entry has been successfully deleted.')</script>";
            return(RedirectToAction("Index", "PostGraduation", new { id = previousEmployment.StudentID }));
        }
 public ActionResult Edit([Bind(Include = "ID,StudentID,Position, Employer, StartMonthId,StartYear,EndMonthId,EndYear")] PreviousEmployment previousEmployment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(previousEmployment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "PostGraduation", new { id = previousEmployment.StudentID }));
     }
     ViewBag.EndMonthId   = new SelectList(db.CommonFields.Where(g => g.Category == "Months"), "ID", "Name", previousEmployment.EndMonthId);
     ViewBag.StartMonthId = new SelectList(db.CommonFields.Where(g => g.Category == "Months"), "ID", "Name", previousEmployment.StartMonthId);
     ViewBag.StudentID    = previousEmployment.StudentID;
     return(View(previousEmployment));
 }
        // GET: PreviousEmployment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PreviousEmployment previousEmployment = db.PreviousEmployment.Find(id);

            if (previousEmployment == null)
            {
                return(HttpNotFound());
            }
            return(View(previousEmployment));
        }
        // GET: PreviousEmployment/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                TempData["msg"] = "<script>alert('Sorry! No record found to delete.')</script>";
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PreviousEmployment previousEmployment = db.PreviousEmployment.Find(id);

            if (previousEmployment == null)
            {
                TempData["msg"] = "<script>alert('Sorry! No record found to delete.')</script>";
                return(HttpNotFound());
            }
            int sendId = (int)id;

            return(DeleteConfirmed(sendId));
        }
        // GET: PreviousEmployment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PreviousEmployment previousEmployment = db.PreviousEmployment.Find(id);
            Student            student            = previousEmployment.Student;

            if (previousEmployment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EndMonthId   = new SelectList(db.CommonFields.Where(g => g.Category == "Months"), "ID", "Name", previousEmployment.EndMonthId);
            ViewBag.StartMonthId = new SelectList(db.CommonFields.Where(g => g.Category == "Months"), "ID", "Name", previousEmployment.StartMonthId);
            ViewBag.Student      = previousEmployment.Student;
            ViewBag.StudentID    = previousEmployment.StudentID;
            return(View(previousEmployment));
        }
예제 #7
0
        public IHttpActionResult PutPreviousEmployment(string id, PreviousEmployment previousemployment)
        {
            try
            {
                previousemployment.Employee_id = DatabaseAction.GetEmployeeID(id);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }


                db.Entry(previousemployment).State = EntityState.Modified;

                db.SaveChanges();
                return(Ok("Previous Employment Details Updated Successfully"));
            }
            catch (Exception ex)
            {
                LogFile.WriteLog(ex);
                return(BadRequest());
            }
        }