Пример #1
0
    public Transaction?MapToModelOrNull(TransactionEntity?entity)
    {
        if (entity is null)
        {
            return(null);
        }

        var model = Transaction.Create(entity.Id, entity.Date, entity.Amount, entity.Description, entity.AccountId,
                                       entity.CategoryId, entity.UserId);

        if (entity.CashflowId is not null)
        {
            model = model.ApplyCashflow(entity.CashflowId.GetValueOrDefault(), entity.CashflowDate.GetValueOrDefault());
        }

        return(model.SetTags(_tagsMapper.Map(entity.Tags)));
    }
Пример #2
0
        public ActionResult Details(string name)
        {
            TagViewModel item = TagsMapper.Map(_tagsService.Get(name));

            if (User.Identity.IsAuthenticated)
            {
                ViewBag.CurrentUser = UsersMapper.Map(_currentUserService.GetDTO);
            }

            return(View(item));
        }
Пример #3
0
        /// <summary>
        /// Loads tag by name and returns tag DTO.
        /// </summary>
        public TagDTO Get(string name)
        {
            Tag tag = _unitOfWork.Tags.Find(t => t.Name == name).FirstOrDefault();

            if (tag != null)
            {
                return(TagsMapper.Map(tag));
            }

            return(null);
        }
Пример #4
0
    public Cashflow?MapToModelOrNull(CashflowEntity?entity)
    {
        if (entity is null)
        {
            return(null);
        }

        var model = new Cashflow()
        {
            Id            = entity.Id,
            AccountId     = entity.AccountId,
            Amount        = entity.Amount,
            CategoryId    = entity.CategoryId,
            Description   = entity.Description,
            EffectiveDate = entity.EffectiveDate,
            Frequency     = entity.Frequency,
            Inactive      = entity.Inactive,
            IntervalType  = entity.IntervalType,
            Recurrence    = entity.Recurrence,
            UserId        = entity.UserId
        };

        return(model.SetTags(_tagsMapper.Map(entity.Tags)));
    }
Пример #5
0
 public TagViewModel Get(string name)
 {
     return(TagsMapper.Map(_tagsService.Get(name)));
 }