Ejemplo n.º 1
0
        public IActionResult Create([FromBody] ProfileMasterDTO dto)
        {
            var Res = _Mapper.Map <ProfilesMaster>(dto);

            try
            {
                var profilesmaster = _profilesmasterRepository.SaveOrUpdateAsync(Res);
                return(Ok(profilesmaster));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Details(int?id, ProfileMasterDTO dto)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var profilesmaster = await _profilesmasterRepository.GetByIdAsync(id);

            var cto = _Mapper.Map <ProfileMasterDTO>(profilesmaster);

            if (profilesmaster == null)
            {
                return(NotFound());
            }
            return(Ok(cto));
        }
Ejemplo n.º 3
0
        public IActionResult Update(int id, [FromBody] ProfileMasterDTO dto)
        {
            // map dto to entity and set id
            var Profile = _Mapper.Map <ProfilesMaster>(dto);

            Profile.Id = id;

            try
            {
                // save
                _profilesmasterRepository.UpdateAsync(Profile, id);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(ex.Message));
            }
        }