예제 #1
0
        public void CreateUserFromModel <TModel>(TModel modelParam)
        {
            User userEntity = _mapperManager.MapModel <TModel, User>(modelParam);

            if (userEntity != null)
            {
                using (_unitOfWork = DIManager.UnitOfWork)
                {
                    _unitOfWork.PersonalAccountantContext.Set <User>().Add(userEntity);
                    _unitOfWork.Save();
                }
            }
        }
예제 #2
0
        public JsonResult AddPlan(AddPlanToStoreModel model)
        {
            AddPlanToStoreWithUser modelToSend = _mapperManager.MapModel <AddPlanToStoreModel, AddPlanToStoreWithUser>(model);

            modelToSend.UserId = Convert.ToInt32(User.Identity.Name);
            _planManager.AddPlan(modelToSend);
            return(Json(null));
        }
예제 #3
0
 public CurrencyNameIdRateClass GetCurrencyWithCurrentName(string nameParam)
 {
     using (_unitOfWork = DIManager.UnitOfWork)
     {
         Currency contextCurrency = _unitOfWork.PersonalAccountantContext.Set <Currency>().FirstOrDefault(x => x.Name.ToUpper() == nameParam.ToUpper());
         return(_mapperHelper.MapModel <Currency, CurrencyNameIdRateClass>(contextCurrency));
     }
 }
예제 #4
0
        /// <summary>
        /// Create new entity to DB from model
        /// </summary>
        /// <typeparam name="TModel">type of model to create from</typeparam>
        /// <typeparam name="TEntity">type of entity to create</typeparam>
        /// <param name="modelParam">instanst of model</param>
        public void CreateEntityFromModelForPersAccount <TModel, TEntity>(TModel modelParam) where TEntity : class, new()
        {
            TEntity newEntity = _mapperManager.MapModel <TModel, TEntity>(modelParam);

            if (newEntity != null)
            {
                using (_unitOfWork = DIManager.UnitOfWork)
                {
                    _unitOfWork.PersonalAccountantContext.Set <TEntity>().Add(newEntity);
                    _unitOfWork.Save();
                }
            }
        }
예제 #5
0
        public NameIdClassModel GetCategoryWithCurrentName(string nameParam)
        {
            using (_unitOfWork = DIManager.UnitOfWork)
            {
                OperationSource contextSource = _unitOfWork.PersonalAccountantContext.Set <OperationSource>().FirstOrDefault(x => x.Name.ToUpper() == nameParam.ToUpper());
                if (contextSource == null)
                {
                    int Id = 0;
                    contextSource = Int32.TryParse(nameParam, out Id) ?
                                    _unitOfWork.PersonalAccountantContext.Set <OperationSource>().FirstOrDefault(x => x.Id == Id) :
                                    CreateNewInstance(nameParam);
                }

                return(_mapperManager.MapModel <OperationSource, NameIdClassModel>(contextSource));
            }
        }
예제 #6
0
        public NameIdClassModel GetAgentWithCurrentName(string nameParam)
        {
            using (_unitOfWork = DIManager.UnitOfWork)
            {
                debt_DebtAgent contextAgent = _unitOfWork.PersonalAccountantContext.Set <debt_DebtAgent>().FirstOrDefault(x => x.Name.ToUpper() == nameParam.ToUpper());
                if (contextAgent == null)
                {
                    int Id = 0;
                    contextAgent = Int32.TryParse(nameParam, out Id) ?
                                   _unitOfWork.PersonalAccountantContext.Set <debt_DebtAgent>().FirstOrDefault(x => x.Id == Id) :
                                   CreateNewInstance(nameParam);
                }

                return(_mapperManager.MapModel <debt_DebtAgent, NameIdClassModel>(contextAgent));
            }
        }
        public NameIdClassModel GetCategoryWithCurrentName(string nameParam, DBModelManagers.Abstract.OperationType operationTypeParam)
        {
            using (_unitOfWork = DIManager.UnitOfWork)
            {
                int operationTypeId = Convert.ToInt32(operationTypeParam);
                OperationCategory contextCategory = _unitOfWork.PersonalAccountantContext.Set <OperationCategory>().
                                                    FirstOrDefault <OperationCategory>(x => x.Name.ToUpper() == nameParam.ToUpper() && x.OperationTypeId == operationTypeId);

                if (contextCategory == null)
                {
                    int Id = 0;
                    contextCategory = Int32.TryParse(nameParam, out Id) ?
                                      _unitOfWork.PersonalAccountantContext.Set <OperationCategory>().FirstOrDefault(x => x.Id == Id && x.OperationTypeId == operationTypeId) :
                                      CreateNewCategory(nameParam, operationTypeParam);
                }

                return(_mapperManager.MapModel <OperationCategory, NameIdClassModel>(contextCategory));
            }
        }