public async Task <bool> Add(User user, Type type)
 {
     try
     {
         type.fk_UserId = user.Id;
         return(_typeRepository.Add(type));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 private void ProcessTypeFromExistingTopic(Type type)
 {
     if (IsValidString(type.Name))
     {
         Type typeByName = typeRepository.GetByCondition(t => t.Name == type.Name &&
                                                         t.Topic.Name == type.Topic.Name);
         if (typeByName == null)
         {
             type.CreationDate     = DateTime.Now;
             type.Id               = Guid.NewGuid();
             type.IsActive         = true;
             type.AdditionalFields = new List <AdditionalField>();
             type.Topic            = topicRepository.GetByCondition(t => t.Name == type.Topic.Name &&
                                                                    t.Area.Name == type.Topic.Area.Name);
             typeRepository.Add(type);
             typeRepository.SaveChanges();
         }
         else
         {
             throw new ImportException($"Error on import: Type: {type.Name} from Topic: {type.Topic.Name} from Area: {type.Topic.Area.Name} already exists");
         }
     }
     else
     {
         throw new ImportException($"Error on import: Type from Topic: {type.Topic.Name} from Area: {type.Topic.Area.Name} was invalid");
     }
 }
示例#3
0
        public void Create(string description)
        {
            TypeEntity type = new TypeEntity();

            type.Description = description;
            _typeRepository.Add(type);
        }
示例#4
0
 public Type Add(Type type)
 {
     if (_typeRepository.CheckContains(x => x.Name == type.Name))
     {
         throw new NameDuplicatedException("Tên không được trùng");
     }
     return(_typeRepository.Add(type));
 }
示例#5
0
 public IActionResult PostType([FromBody] Type type)
 {
     using (var scope = new TransactionScope())
     {
         _typeRepository.Add(type);
         scope.Complete();
         return(CreatedAtAction(nameof(GetRoom), new { id = type.TypeId }, type));
     }
 }
示例#6
0
 public Type Create(Type type)
 {
     typeValidator.ValidateAdd(type);
     GiveNewTypeFormat(type);
     FormatAdditionalFields(type);
     typeRepository.Add(type);
     typeRepository.SaveChanges();
     return(type);
 }
示例#7
0
 public void createType(Data.Type obj)
 {
     try
     {
         TypeRepository.Add(obj);
         SaveChange();
     }
     catch
     {
     }
 }
    public static ITypeRepository Extend(this ITypeRepository target, ITypeRepository source)
    {
        _ = target ?? throw new ArgumentNullException(nameof(target));
        _ = source ?? throw new ArgumentNullException(nameof(source));

        foreach (var item in source.GetAll() ?? Enumerable.Empty <KeyValuePair <Type, Type> >())
        {
            if (!target.TryGet(item.Key, out _))
            {
                target.Add(item.Key, item.Value);
            }
        }
        return(target);
    }
        public void InsertType(TypeViewModel type)
        {
            type.Status = (int)DbConstant.DefaultDataStatus.Active;
            using (var trans = _unitOfWork.BeginTransaction())
            {
                try
                {
                    Type entity = new Type();
                    Map(type, entity);
                    _typeRepository.Add(entity);
                    _unitOfWork.SaveChanges();

                    trans.Commit();
                }
                catch (System.Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }
        }
 public bool AddType(TypeMasterVM _TypeVM)
 {
     try
     {
         if (_TypeVM != null)
         {
             tblTypeMaster _type = new tblTypeMaster();
             _type.Type      = _TypeVM.Type;
             _type.TypeId    = _TypeVM.TypeId;
             _type.IsDeleted = false;
             _TypeRepository.Add(_type);
             _unitOfWork.Complete();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#11
0
        /// <summary>
        /// Add new Tax value
        /// </summary>
        /// <param name="obj">Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel Add(Model.Models.Type obj)
        {
            var result   = new Model.Models.Type();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                result = _TypeRepository.Add(obj);
                _unitOfWork.Commit();
                response.Message = CommonConstants.AddSuccess;
                response.Result  = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }
示例#12
0
 public void Create(string description)
 {
     Models.Type type = new Models.Type();
     type.Description = description;
     _typeRepository.Add(type);
 }
 public void Add(Type type)
 {
     _typeRepository.Add(type);
     _unitOfWork.SaveChanges();
 }
示例#14
0
 public void Add(TypeDTO entity)
 {
     _typeRepository.Add(entity);
 }
示例#15
0
        public void Add(TypeViewModel typeVm)
        {
            var type = Mapper.Map <TypeViewModel, BeCoreApp.Data.Entities.Type>(typeVm);

            _typeRepository.Add(type);
        }