Beispiel #1
0
        public IHttpActionResult AddUser(DeptRightViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var emp = new EmployeeService().GetEmployeeByNo(vm.empno);
                    var req = _reqservice.GetRequestApplicationById(vm.formid);

                    DeptAccessRight dar = new DeptAccessRight()
                    {
                        DeptId = vm.deptid,
                        UserId = emp.id,
                        ReqApp = req.RequestCode,
                        CreatedBy = RequestContext.Principal.Identity.Name,
                        CreatedDate = DateTime.Now,
                        Sync = false,
                        Status = (vm.active ? "ACTIVE" : "INACTIVE")
                    };

                    _deptRightService.Add(dar);

                    return Ok(true);
                }
                catch (SmartException ex)
                {
                    return BadRequest(ex.Message);
                }
            }

            return BadRequest(ModelState);
        }
Beispiel #2
0
        public IHttpActionResult UpdateUser(DeptRightViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    DeptAccessRight dar = _deptRightService.GetDeptAccessRightById(vm.id);

                    dar.ModifiedDate = DateTime.Now;
                    dar.ModifiedBy = RequestContext.Principal.Identity.Name;
                    dar.Status = (vm.active ? "ACTIVE" : "INACTIVE");

                    _deptRightService.Update(dar);

                    return Ok(true);
                }
                catch (SmartException ex)
                {
                    return BadRequest(ex.Message);
                }
            }

            return BadRequest(ModelState);
        }