示例#1
0
        public ResponseModel <MsGroup> Create(MsGroupDto msGroup)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            try
            {
                _logger.LogInformation($"Start Function => {methodName}, Parameters => {JsonSerializer.ToJsonString(msGroup)}");

                var _group = new MsGroup
                {
                    IdGroup    = Guid.NewGuid(),
                    Name       = msGroup.Name,
                    CreateBy   = "System",
                    CreateDate = DateTime.Now
                };
                _context.MsGroup.Add(_group);
                _context.SaveChanges();

                _logger.LogInformation($"Finish Function => {methodName}, Result => {JsonSerializer.ToJsonString(_group)}");

                return(new ResponseModel <MsGroup>
                {
                    Success = true,
                    Datas = _group,
                });
            }
            catch (Exception ex)
            {
                var messageError = $"Error Function => {methodName}";
                _logger.LogError(ex, messageError);
                throw new ArgumentException(messageError, ex);
            }
        }
示例#2
0
        public ResponseModel Update(MsGroup msGroups)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            try
            {
                _logger.LogInformation($"Start Function => {methodName}, Parameters => {JsonSerializer.ToJsonString(msGroups)}");

                _context.MsGroup.Update(msGroups);
                _context.SaveChanges();

                _logger.LogInformation($"Finish Function => {methodName}, Result => {JsonSerializer.ToJsonString(msGroups)}");

                return(new ResponseModel
                {
                    Success = true,
                });
            }
            catch (Exception ex)
            {
                var messageError = $"Error Function => {methodName}";
                _logger.LogError(ex, messageError);
                throw new ArgumentException(messageError, ex);
            }
        }
示例#3
0
        public ResponseModel Delete(MsGroup msGroups)
        {
            var result = new ResponseModel();

            try
            {
                result = _msGroupService.Delete(msGroups);
                return(result);
            }
            catch
            {
                return(new ResponseModel
                {
                    Message = result.Message,
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }
        public ResponseModel GetQuestionById(MsGroup msGroup)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            try
            {
                _logger.LogInformation($"Start Function => {methodName}");


                //var q = _context.MsQuestion.ToList();
                //var c = _context.ConfigGroupQuestion.ToList();


                var datas = (from config in _context.ConfigGroupQuestion
                             join question in _context.MsQuestion on config.IdQuestion equals question.IdQuestion
                             where (question.IsActive == true && config.IdGroup == msGroup.IdGroup)
                             select new ConfigGroupQuestionModel
                {
                    IdConfigGroupQuestion = config.IdConfigGroupQuestion,
                    IdGroup = config.IdGroup,
                    IdQuestion = config.IdQuestion,
                    Name = question.Name,
                    CreateBy = config.CreateBy,
                    CreateDate = config.CreateDate,
                    IsActive = config.IsActive,
                    Order = config.Order
                }).OrderBy(r => r.Order).ToList();

                _logger.LogInformation($"Finish Function => {methodName}");

                return(new ResponseModel
                {
                    Success = true,
                    Datas = datas
                });
            }
            catch (Exception ex)
            {
                var messageError = $"Error Function => {methodName}";
                _logger.LogError(ex, messageError);
                throw new ArgumentException(messageError, ex);
            }
        }