public Result <MediaServiceModel> Update(MediaServiceModel mediaModel, int userId, int groupId)
        {
            var result = new Result <MediaServiceModel>();

            try
            {
                var mediaEntity = _unitOfWork.MediaRepository.GetSingle(x => x.Id == mediaModel.Id && x.IsActive && x.User.Id == userId);
                if (mediaModel != null)
                {
                    mediaEntity.UpdatedBy = userId;
                    mediaEntity.UpdatedOn = Application.CurrentDate;
                    _unitOfWork.MediaRepository.Update(mediaEntity);
                    _unitOfWork.Save();

                    var mediaServiceModel = _mapper.Map <MediaServiceModel>(mediaEntity);
                    result.IsSuccess = true;
                    result.Data      = mediaServiceModel;
                    return(result);
                }
                else
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = ErrorMessage.UpdateUnAuth;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.InnerException.Message);
                result.IsSuccess    = true;
                result.ErrorMessage = ErrorMessage.Update;;
                return(result);
            }
        }
        public Result <MediaServiceModel> Add(MediaServiceModel mediaModel, int userId, int groupId)
        {
            var result = new Result <MediaServiceModel>();

            try
            {
                //map to media entity
                var mediaEntity = new Media
                {
                    Guid      = mediaModel.Guid,
                    Url       = mediaModel.Url,
                    TypeId    = (int)mediaModel.TypeId,
                    CreatedOn = Application.CurrentDate,
                    CreatedBy = userId
                };

                //save to database
                _unitOfWork.MediaRepository.Add(mediaEntity);
                _unitOfWork.Save();

                //map to service model
                var mappedMediaModel = _mapper.Map <MediaServiceModel>(mediaEntity);

                //return result
                result.IsSuccess = true;
                result.Data      = mappedMediaModel;
                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.InnerException.Message);
                result.IsSuccess    = false;
                result.ErrorMessage = ErrorMessage.Add;
                return(result);
            }
        }