public ActionResult AddOrUpdate([Bind(Include = "Id, FirstName, LastName, MiddleName, Position")] EmployeeDetailsView employee)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", employee));
            }

            _logger.Info($"POST Employee/AddOrUpdate {employee}");

            try
            {
                _employeeService.AddOrUpdateEmployee(Mapper.Map <EmployeeDto>(employee));
            }
            catch (EntityNotFoundException ex)
            {
                _logger.Warn(ex.Message);

                ViewBag.Error = ex.Message;

                return(View("Edit", employee));
            }


            return(RedirectToAction(actionName: "List"));
        }
Exemple #2
0
        //==============================================================================


        public EmployeeDetailsViewModel(
            AppRepository <KfsContext> aAppDbRepository, TDStransactionControl aTDStransactionControl)
            : base(aAppDbRepository, aTDStransactionControl)
        {
            _myView             = new EmployeeDetailsView();
            _myView.DataContext = this;


            ItemsFromDB = _appDbRespository.Employee.GetAllForOverview();


            Command_NavigatBack    = new RelayCommand(NavigateBack);
            Command_ToMainMenu     = new RelayCommand(NavigateToMainMenu);
            Command_AddNewEmployee = new RelayCommand(NavigateToNewEmployee);



            Command_DeleteDBitemButtonInDatagridClick = new RelayCommand(DeleteDBitemButtonInDatagridClick);
            Command_UpdateDBitemButtonInDatagridClick = new RelayCommand(UpdateDBitemButtonInDatagridClick);
            //Command_ViewDBitemButtonInDatagridClick = new RelayCommand(ViewDBitemButtonInDatagridClick);
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var employeeId = Request.Params["Id"];

            if (employeeId == null)
            {
                Response.Redirect("Employees.aspx");
            }

            int parsedId = int.Parse(employeeId);

            NorthwindEntities context = new NorthwindEntities();
            var employee = new List <Employee>()
            {
                context.Employees.FirstOrDefault(x => x.EmployeeID == parsedId)
            };

            EmployeeDetailsView.DataSource = employee;
            EmployeeDetailsView.DataBind();

            EmployeeFormView.DataSource = employee;
            EmployeeFormView.DataBind();
        }