Ejemplo n.º 1
0
        public ActionResult Create(EmployeeAbsent employeeAbsent, string PostMethod)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var viewModel = new EmployeeAbsentViewModel
                    {
                        EmployeeAbsent = employeeAbsent,
                        Employee       = _context.Users.ToList()
                    };
                }

                employeeAbsent.ApplicationUserCreatedById     = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4";
                employeeAbsent.ApplicationUserCreatedDate     = DateTime.Now;
                employeeAbsent.ApplicationUserLastUpdatedById = employeeAbsent.ApplicationUserCreatedById;
                employeeAbsent.ApplicationUserLastUpdatedDate = DateTime.Now;
                // TODO: Add insert logic here
                _context.EmployeeAbsents.Add(employeeAbsent);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id, EmployeeAbsent employeeAbsent)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var viewModel = new EmployeeAbsentViewModel
                    {
                        EmployeeAbsent = employeeAbsent,
                        Employee       = _context.Users.ToList()
                    };

                    //return View("CustomerForm", viewModel);
                }
                // TODO: Add update logic here
                var EmpAbsentinDb = _context.EmployeeAbsents.Single(v => v.Id == employeeAbsent.Id);
                EmpAbsentinDb.EmployeeId = employeeAbsent.EmployeeId;
                EmpAbsentinDb.AbsentOn   = employeeAbsent.AbsentOn;

                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
        // GET: EmployeeAbsent/Create
        public ActionResult Create(EmployeeAbsent employeeAbsent)
        {
            var viewModel = new EmployeeAbsentViewModel
            {
                EmployeeAbsent = employeeAbsent,
                Employee       = _context.Users.ToList()
            };

            return(View("Create", viewModel));
        }
Ejemplo n.º 4
0
        // GET: EmployeeAbsent/Edit/5
        public ActionResult Edit(int id)
        {
            var employeeAbsent = _context.EmployeeAbsents.SingleOrDefault(c => c.Id == id);

            if (employeeAbsent == null)
            {
                return(RedirectToAction("Index"));
            }

            var viewModel = new EmployeeAbsentViewModel
            {
                EmployeeAbsent = employeeAbsent,
                Employee       = _context.Users.ToList()
            };

            return(View(viewModel));
        }