public ActionResult Edit(int?id, EmployeeEdit newItem)
        {
            try
            {
                // TODO: Add update logic here
                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
                }
                if (id.GetValueOrDefault() != newItem.EmployeeId)
                {
                    return(RedirectToAction("Index"));
                }

                var editform = m.EmployeeEdit(newItem);

                if (editform == null)
                {
                    return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
                }
                else
                {
                    return(RedirectToAction("details", new { id = newItem.EmployeeId }));
                }
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        public ActionResult Edit(int?id, EmployeeEdit newItem)
        {
            // Validate the input
            if (!ModelState.IsValid)
            {
                // Our "version 1" approach is to display the "edit form" again
                return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
            }

            if (id.GetValueOrDefault() != newItem.EmployeeId)
            {
                // This appears to be data tampering, so redirect the user away
                return(RedirectToAction("index"));
            }

            // Attempt to do the update
            var editedItem = m.EmployeeEdit(newItem);

            if (editedItem == null)
            {
                // There was a problem updating the object
                // Our "version 1" approach is to display the "edit form" again
                return(RedirectToAction("edit", new { id = newItem.EmployeeId }));
            }
            else
            {
                // Show the details view, which will have the updated data
                return(RedirectToAction("details", new { id = newItem.EmployeeId }));
            }
        }
        public EmployeeBase EmployeeEditContactInfo(EmployeeEdit e)
        {
            var o = ds.Employees.Find(e.EmployeeId);

            if (o != null)
            {
                ds.Entry(o).CurrentValues.SetValues(e);
                ds.SaveChanges();
                return Mapper.Map<Employee, EmployeeBase>(o);
            }
            return null;
        }//EmployeeEditContactInfo
        public ActionResult Edit(int id, EmployeeEdit e)
        {
            try
            {
                var obj = m.EmployeeEditContactInfo(e);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 5
0
        public EmployeeBase EmployeeEdit(EmployeeEdit EEF)
        {
            var o = ds.Employees.Find(EEF.EmployeeId);

            if (o == null)
            {
                return(null);
            }
            else
            {
                ds.Entry(o).CurrentValues.SetValues(EEF);
                ds.SaveChanges();
                return(Mapper.Map <Employee, EmployeeBase>(o));
            }
        }
Esempio n. 6
0
        public EmployeeBase EmployeeEdit(EmployeeEdit 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 <EmployeeBase>(o));
            }
        }
Esempio n. 7
0
        public ActionResult Edit(int id, EmployeeEdit collection)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("edit", new { id = collection.EmployeeId }));
            }
            if (id != collection.EmployeeId)
            {
                return(RedirectToAction("index"));
            }

            var editedItem = m.EmployeeEdit(collection);

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