Exemple #1
0
        public ActionResult Update(Models.Search _search)
        {
            string retval = string.Empty;

            using (SoumavoEntities _ent = new SoumavoEntities())
            {
                var result = (from a in _ent.Employees where a.Id.Equals(_search.Id) select a).FirstOrDefault();

                if (result != null)
                {
                    Employee _emp = new Employee()
                    {
                        FromDate = _search.FromDate,
                        Name     = _search.Name,
                        Payment  = _search.PaymentName,
                        ToDate   = _search.ToDate,
                        Vehicle  = _search.VehicleName,
                        Id       = _search.Id,
                    };
                    _ent.Entry(result).CurrentValues.SetValues(_emp);
                    _ent.SaveChanges();
                    TempData["Message"] = "Updated Successfully";
                }
                else
                {
                    TempData["Message"] = "Error Occured";
                }
            }
            return(RedirectToAction("SeeData"));
        }
Exemple #2
0
        public ActionResult Delete(int id)
        {
            bool res = false;

            using (SoumavoEntities _ent = new SoumavoEntities())
            {
                var result = (from a in _ent.Employees where a.Id.Equals(id) select a).FirstOrDefault();
                if (result != null)
                {
                    _ent.Employees.Remove(result);
                    _ent.SaveChanges();
                    res = true;
                }
            }
            return(Json(res));
        }
Exemple #3
0
 public ActionResult Search(Models.Search _search)
 {
     //Save the data to Database
     if (_search != null)
     {
         using (SoumavoEntities _ent = new SoumavoEntities())
         {
             Employee _emp = new Employee()
             {
                 Name     = _search.Name,
                 FromDate = Convert.ToDateTime(Convert.ToDateTime(_search.FromDate).ToShortDateString()),
                 ToDate   = Convert.ToDateTime(Convert.ToDateTime(_search.ToDate).ToShortDateString()),
                 Payment  = _search.PaymentName,
                 Vehicle  = _search.VehicleName
             };
             _ent.Employees.Add(_emp);
             _ent.SaveChanges();
             TempData["Message"] = "Saved";
         }
     }
     return(RedirectToAction("Search", "Home"));
 }