Exemplo n.º 1
0
        public FinanceUserViewModel Find(string userName)
        {
            FinanceUser          fUser = _repository.FindOne(a => a.UserName == userName);
            FinanceUserViewModel user  = new FinanceUserViewModel()
            {
                Id       = (int)fUser?.Id,
                Name     = fUser?.Name,
                UserName = fUser?.UserName
            };

            return(user);
        }
        public int Create(FianceProjectViewModel projVM)
        {
            var bills = new List <Bill>();

            bills.Add(new Bill
            {
                Balance = 0,
                Group   = null,
                Name    = "Main"
            });
            var owner   = _fUserRepo.FindOne(a => a.Id == projVM.OwnerId);
            var members = new List <FinanceUser>();

            members.Add(owner);
            _fProjRepo.Add(new FinanceProject {
                Id = projVM.Id, Name = projVM.Name, Owner = owner, Bills = bills, Members = members
            });
            _fProjRepo.Save();
            var tempProj = _fProjRepo.FindOne(p => p.Name == projVM.Name);

            return(tempProj.Id);
        }