public ActionResult EmploymentSave(long?id, DateTime?start, DateTime?end, string remarks, long staffid)
        {
            var employment = new employment();

            if (id.HasValue)
            {
                employment = repository.GetEmploymentPeriod(id.Value);
            }
            employment.start_date = start;
            employment.end_date   = end;
            employment.remarks    = remarks;

            if (!id.HasValue)
            {
                employment.userid = staffid;
                db.employments.InsertOnSubmit(employment);
            }

            repository.Save();

            var viewmodel = "Entry updated successfully".ToJsonOKMessage();

            viewmodel.data = this.RenderViewToString("EmploymentRow", new[] { employment.ToModel() });

            return(Json(viewmodel));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            employment employment = db.employment.Find(id);

            db.employment.Remove(employment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "id,id_work,id_executor")] employment employment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_work     = new SelectList(db.work, "id", "desc_work", employment.id_work);
     ViewBag.id_executor = new SelectList(db.executor, "id", "FIO", employment.id_executor);
     return(View(employment));
 }
 public static EmploymentPeriod ToModel(this employment row)
 {
     return(new EmploymentPeriod()
     {
         id = row.id.ToString(),
         startDate = row.start_date.HasValue
                         ? row.start_date.Value.ToString(Constants.DATETIME_SHORT_DATE)
                         : "",
         endDate = row.end_date.HasValue
                       ? row.end_date.Value.ToString(Constants.DATETIME_SHORT_DATE)
                       : "",
         remarks = row.remarks
     });
 }
Exemple #5
0
        // GET: employments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            employment employment = db.employment.Find(id);

            if (employment == null)
            {
                return(HttpNotFound());
            }
            return(View(employment));
        }
Exemple #6
0
        // GET: employments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            employment employment = db.employment.Find(id);

            if (employment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_work     = new SelectList(db.work, "id", "desc_work", employment.id_work);
            ViewBag.id_executor = new SelectList(db.executor, "id", "FIO", employment.id_executor);
            return(View(employment));
        }