示例#1
0
 public Interest FromInterestViewModelToInterest(InterestViewModel interestViewModel)
 {
     return(new Interest
     {
         Description = interestViewModel.Description
     });
 }
        public ActionResult Interest()
        {
            var model = new InterestViewModel();

            model.Rate = 12.5;
            return(View(model));
        }
        public ActionResult Interest(InterestViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Interest = model.Amount * model.Rate / 100;
            }

            return(View(model));
        }
示例#4
0
        public IActionResult Manage()
        {
            InterestViewModel interestData = new InterestViewModel
            {
                Interests = dataRepository.GetAllInterests().ToList()
            };

            logger.LogInformation("Admin navigated to Interest Management Page");
            return(View(interestData));
        }
示例#5
0
        private bool AddInterest(string userId, InterestViewModel interest)
        {
            var addRecord = new InterestDto()
            {
                UserId  = userId,
                Title   = interest.Title,
                Summary = interest.Summary
            };

            return(_interestService.InsertInterest(userId, addRecord));
        }
        // GET: Interests
        public ActionResult Index(int id)
        {
            var interests = _context.Interests.Where(i => i.PersonId == id).ToList();
            var viewModel = new InterestViewModel
            {
                Interests = interests,
                PersonId  = id
            };

            return(View(viewModel));
        }
示例#7
0
        public async Task <IActionResult> Interest(InterestViewModel model)
        {
            string msg = null;

            if (ModelState.IsValid)
            {
                DateTime date = new LatestInterestDateQuery().Get(_context, model.Interest.AccountId);
                msg = await new InterestCommand().RunAsync(_context, model.Interest, date, 0.10m);
            }
            model.Message = msg;
            return(View(model));
        }
示例#8
0
        private bool UpdateInterest(string userId, InterestViewModel interest)
        {
            var updateRecord = new InterestDto()
            {
                Id      = interest.Id,
                UserId  = userId,
                Title   = interest.Title,
                Summary = interest.Summary
            };

            return(_interestService.UpdateInterest(userId, updateRecord));
        }
示例#9
0
        public IActionResult ApplyInterest(InterestViewModel model)
        {
            var command = new ApplyInterestCommand {
                AccountId = 1, Amount = 1, PreviousApplication = DateTime.Parse("2018-05-28")
            };
            var handler = new ApplyInterestHandler(new BankContext());

            handler.Handler(command);

            TempData["success"] = "Interest applied succesfully";
            return(View());
        }
示例#10
0
        public async Task <IActionResult> Create(int AnimalID)
        {
            System.Security.Claims.ClaimsPrincipal currentUser = this.User;

            Animal animal = await _animalHttpRepository.HttpGetByID(AnimalID);

            var vm = new InterestViewModel
            {
                Animal = animal
            };

            return(View(vm));
        }
示例#11
0
 public IActionResult Create([FromBody] InterestViewModel interestViewModel)
 {
     try
     {
         Interest interest = interestMapper.FromInterestViewModelToInterest(interestViewModel);
         serviceInterest.AddInterest(interest);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
示例#12
0
        public ActionResult EditInterest(InterestViewModel interest)
        {
            if (ModelState.IsValid)
            {
                var isUpdated = UpdateInterest(User.Identity.GetUserId(), interest);
                if (isUpdated)
                {
                    return(Json(new { success = true }));
                }
            }

            return(PartialView("_EditInterest", interest));
        }
示例#13
0
        public IActionResult Update([FromBody] InterestViewModel interestViewModel, int id)
        {
            try
            {
                Interest interest = serviceInterest.GetInterestById(id);

                interest.Description = interestViewModel.Description;

                serviceInterest.UpdateInterest(interest);

                return(Ok(ToOutputModel(interest)));
            }
            catch
            {
                return(BadRequest());
            }
        }
示例#14
0
        public async Task <IActionResult> Create(InterestViewModel interest)
        {
            System.Security.Claims.ClaimsPrincipal currentUser = this.User;
            Animal animal = await _animalHttpRepository.HttpGetByID(interest.Animal.ID);

            try
            {
                await _interestHttpRepository.ShowInterest(animal, currentUser);
            } catch (InvalidOperationException e)
            {
                ViewBag.Message = "Already displayed interest in this animal";
                return(View(interest));
            }

            ViewBag.Message = "Interest added";
            return(View(interest));
        }
        public ActionResult Create(InterestViewModel interest)
        {
            if (ModelState.IsValid)
            {
                GeneralUser     user    = db.Users.FirstOrDefault(u => u.Email == User.Identity.Name);
                FieldOfInterest foi     = db.Fields.FirstOrDefault(f => f.Id == interest.FOIId);
                UserFOI         userFOI = new UserFOI()
                {
                    User  = user,
                    Foi   = foi,
                    Level = interest.Level
                };
                db.UserFOIs.Add(userFOI);
                db.SaveChanges();
                return(RedirectToAction("Index", user is StudentUser ? "student" : "providers", null));
            }

            return(View(interest));
        }
示例#16
0
        private InterestViewModel GetInterest(string userId, string interestId)
        {
            var interest = _interestService.GetInterestById(userId, interestId);

            if (interest == null)
            {
                return(null);
            }


            var result = new InterestViewModel()
            {
                Id         = interest.Id,
                Title      = interest.Title,
                Summary    = interest.Summary,
                CreateDate = interest.CreateDate
            };

            return(result);
        }
示例#17
0
        public async Task <IActionResult> Interest()
        {
            InterestViewModel vm           = new InterestViewModel();
            IdentityUser      identityUser = await _userManager.GetUserAsync(User);

            //Recuperando Interesses
            var query = from i in _context.Donations select i;

            query = query.Where(i => i.donatario.userId == identityUser.Id);

            List <Donation> interesses = await query.ToListAsync();

            foreach (var item in interesses)
            {
                item.doador = await _context.Users.FirstOrDefaultAsync(u => u.userId == item.doadoruserId);

                item.doacao = await _context.Pets.FirstOrDefaultAsync(p => p.petId == item.doacaopetId);

                item.donatario = await _context.Users.FirstOrDefaultAsync(u => u.userId == item.donatariouserId);
            }
            vm.interesses = interesses; //pets que eu demonstrei interesse

            //Recuperando Interessados
            var query2 = from i in _context.Donations select i;

            query2 = query2.Where(i => i.doador.userId == identityUser.Id);

            List <Donation> interessados = await query2.ToListAsync();

            foreach (var item in interessados)
            {
                item.doador = await _context.Users.FirstOrDefaultAsync(u => u.userId == item.doadoruserId);

                item.doacao = await _context.Pets.FirstOrDefaultAsync(p => p.petId == item.doacaopetId);

                item.donatario = await _context.Users.FirstOrDefaultAsync(u => u.userId == item.donatariouserId);
            }
            vm.interessados = interessados; //pets que usuários ficaram interessados

            return(View(vm));
        }
        // GET: Interests
        public ActionResult Index()
        {
            var currentUser = User.Identity.GetUserId();

            if (currentUser == null)
            {
                return(RedirectToAction("Login", "AccountControler"));
            }
            else
            {
                var interests = (from ints in _db.Interests.Include("Product")
                                 where ints.UserId == currentUser
                                 select ints).OrderByDescending(x => x.Date);

                var model = new InterestViewModel {
                    Interests = interests.ToList()
                };

                return(View(model));
            }
        }
        public IHttpActionResult AddUserInterest(InterestViewModel interest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            GeneralUser     user    = db.Users.FirstOrDefault(u => u.Email == User.Identity.Name);
            FieldOfInterest foi     = db.Fields.FirstOrDefault(f => f.Id == interest.FOIId);
            UserFOI         userFOI = new UserFOI()
            {
                User  = user,
                Foi   = foi,
                Level = interest.Level
            };

            db.UserFOIs.Add(userFOI);
            db.SaveChanges();

            return(Ok());
        }
        public IActionResult addUserInterest(InterestViewModel userInterest, string salary, string divorced, string widowed,
                                             string ethnicity, string userBio)
        {
            User currentUser = getCurrentUser();
            int  height      = (userInterest.feet * 12) + userInterest.inch;

            currentUser.height = height;
            currentUser.salary = salary;
            currentUser.music  = userInterest.weed;
            currentUser.build  = userInterest.body;
            currentUser.pets   = userInterest.pets;
            currentUser.diet   = userInterest.diet;
            currentUser.kids   = userInterest.kids;

            currentUser.Divorced = (userInterest.divorced == "Yes");
            currentUser.Widowed  = (userInterest.widowed == "Yes");

            currentUser.ethnicity = userInterest.ethnicity;
            currentUser.drinking  = userInterest.drinking;
            currentUser.religion  = userInterest.religion;
            currentUser.bio       = userBio;
            _context.SaveChanges();
            return(Redirect("/preferences"));
        }
示例#21
0
        public IActionResult addUserInterest(InterestViewModel userInterest, string salary, string divorced, string widowed, string ethnicity, string userBio)
        {
            int? currentUserId = HttpContext.Session.GetInt32("currentUser");
            User currentUser   = _context.Users.SingleOrDefault(findUser => findUser.UserId == currentUserId);
            int  height        = (userInterest.feet * 12) + userInterest.inch;

            currentUser.height    = height;
            currentUser.salary    = salary;
            currentUser.marijuana = userInterest.weed;
            currentUser.build     = userInterest.body;
            currentUser.pets      = userInterest.pets;
            currentUser.diet      = userInterest.diet;
            currentUser.kids      = userInterest.kids;
            if (userInterest.divorced == "Yes")
            {
                currentUser.Divorced = true;
            }
            else
            {
                currentUser.Divorced = false;
            }
            if (userInterest.widowed == "Yes")
            {
                currentUser.Widowed = true;
            }
            else
            {
                currentUser.Widowed = false;
            }
            currentUser.ethnicity = userInterest.ethnicity;
            currentUser.drinking  = userInterest.drinking;
            currentUser.religion  = userInterest.religion;
            currentUser.bio       = userBio;
            _context.SaveChanges();
            return(Redirect("/preferences"));
        }
示例#22
0
 public InterestView(InterestViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }