Exemplo n.º 1
0
        // GET: MusicShop
        public ActionResult Index(string type, string searchString)
        {
            string   ipAddress = IpGetter.GetIPAddress();
            IpRecord record    = db.IpRecords.Where(ip => ip.IpAddress == ipAddress).SingleOrDefault();

            if (record == null)
            {
                IpRecord newRecord = new IpRecord()
                {
                    IpAddress       = ipAddress,
                    TimeOfRecord    = DateTime.UtcNow,
                    LastTimeOfIssue = DateTime.UtcNow
                };
                db.IpRecords.Add(newRecord);
                db.SaveChanges();
            }
            else
            {
                record.LastTimeOfIssue = DateTime.UtcNow;
                db.Entry(record).State = EntityState.Modified;
                db.SaveChanges();
            }

            InstrumentType insType = InstrumentType.Guitar;

            ViewBag.type = new SelectList(Enum.GetValues(typeof(InstrumentType)));

            var instruments = from ins in db.Instruments
                              select ins;

            if (!string.IsNullOrEmpty(searchString))
            {
                instruments = instruments.Where(s => (s.Manufacturer + " " + s.Model).Contains(searchString));
            }

            if (type != "All" && Enum.TryParse(type, out insType))
            {
                instruments = instruments.Where(s => s.Type == insType);
            }

            return(View(instruments));
        }
Exemplo n.º 2
0
 public void AddAccount(Account account)
 {
     _context.Accounts.Add(account);
     _context.SaveChanges();
 }