Beispiel #1
0
        //To update access rights
        public IHttpActionResult UpdateRoleAndRights(List <RoleRightsMappingModel> rolesRightsModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    RolesData roleRightsData = new RolesData();

                    var config = new MapperConfiguration(cfg =>
                    {
                        //cfg.CreateMap<RolesModel, RolesDTO>();
                        cfg.CreateMap <RoleRightsMappingModel, RoleRightsMappingDTO>();
                    });
                    IMapper mapper = config.CreateMapper();

                    var roleRights = mapper.Map <List <RoleRightsMappingModel>, List <RoleRightsMappingDTO> >(rolesRightsModel);

                    roleRightsData.UpdateRoleAndRights(roleRights);

                    return(Created("api/UpdateRoleAndRights", true));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Could not update rights"));
            }
        }