Beispiel #1
0
        // ProductEdit()
        public EmployeeBase EmployeeEditContactInfo(EmployeeEditContactInfo newItem)
        {
            var o = ds.Employees.Find(newItem.EmployeeId);

            if (o == null)
            {
                return(null);
            }
            else
            {
                ds.Entry(o).CurrentValues.SetValues(newItem);
                ds.SaveChanges();
            }
            return(Mapper.Map <Employee, EmployeeBase>(o));
        }
        public ActionResult Edit(int?id, EmployeeEditContactInfo newItem)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
            }
            if (id.GetValueOrDefault() != newItem.EmployeeId)
            {
                return(RedirectToAction("index"));
            }

            var editedItem = m.EmployeeEditContactInfo(newItem);

            if (editedItem == null)
            {
                return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
            }
            else
            {
                return(RedirectToAction("details", new { id = newItem.EmployeeId }));
            }
        }