Exemplo n.º 1
0
        public async Task <IActionResult> Edit(long id, [Bind("VarroaCountId,BeeHive,DateForCount,NumberOfDaysObserved,Comment")] VarroaCount varroaCount)
        {
            if (id != varroaCount.VarroaCountId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(varroaCount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VarroaCountExists(varroaCount.VarroaCountId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(varroaCount));
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            _varroaCounts = new ObservableCollection <VarroaCount>();

            var vc = new VarroaCount
            {
                Beehive = "TheFarm",
                Date    = DateTime.Today.ToString("dd/MM/yyyy"),
                Count   = 32,
                Notes   = "Shit der var mange mider, den var helt tosset. Vi er ved at dø på farmen."
            };
            var vc2 = new VarroaCount
            {
                Beehive = "TheFarm1",
                Date    = DateTime.Today.ToString("dd/MM/yyyy"),
                Count   = 32,
                Notes   = "Shit der var mange mider, den var helt tosset. Vi er ved at dø på farmen.2"
            };

            CurrentVarroaCount = null;
            _varroaCounts.Add(vc);
            _varroaCounts.Add(vc2);

            FilteredVarroaCounts = new ObservableCollection <VarroaCount>(VarroaCounts);

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += new EventHandler(Timer_Tick);
            timer.Start();
        }
Exemplo n.º 3
0
        private bool CollectionViewSource_Filter(object vc)
        {
            VarroaCount varcount = vc as VarroaCount;

            if (!string.IsNullOrEmpty(BeeHiveName))
            {
                return(varcount.Name.Contains(BeeHiveName));
            }
            return(varcount.Name.Contains(""));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("BeehiveId,User,BeeHiveName,Date,AmountOfVarroa,ObservedDays,Note")] VarroaCount varroaCount)
        {
            if (ModelState.IsValid)
            {
                varroaCount.User = User.Identity.Name;
                _context.Add(varroaCount);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Varroa"));
            }
            return(View("CreateVarroaCount"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("VarroaCountId,BeeHive,DateForCount,NumberOfDaysObserved,Comment, ZipCode")] VarroaCount varroaCount, [FromServices] UserManager <ApplicationUser> userManager)
        {
            if (ModelState.IsValid)
            {
                varroaCount.AuthorOfData = await userManager.GetUserAsync(User);

                varroaCount.IdOfAuthor = varroaCount.AuthorOfData.Id;
                varroaCount.ZipCode    = varroaCount.AuthorOfData.ZipCode;
                _context.Add(varroaCount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(varroaCount));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Beehive,DOC,Varroa,ObservationLength,Comments")] CreationViewModel varroaCount)
        {
            if (!ModelState.IsValid)
            {
                return(View(varroaCount));
            }

            var user = await _userManager.GetUserAsync(User);

            var shortUser = new User
            {
                Email   = user.Email,
                ZipCode = user.ZipCode
            };

            varroaCount.User = shortUser;

            var result = new VarroaCount()
            {
                User              = varroaCount.User,
                Id                = varroaCount.Id,
                Varroa            = varroaCount.Varroa,
                UserId            = varroaCount.UserId,
                Beehive           = varroaCount.Beehive,
                Comments          = varroaCount.Comments,
                DOC               = varroaCount.DOC,
                ObservationLength = varroaCount.ObservationLength
            };


            _context.Add(result);
            _context.Add(shortUser);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 7
0
 public VarroaRecordDetailsViewModel(ref VarroaCount varroaCount)
 {
     Title    = "Bemærkninger for Bistad: " + varroaCount.BistadId;
     Comments = varroaCount.Comment;
 }
Exemplo n.º 8
0
 public VarroaCountViewModel(string title, VarroaCount varroaCount)
 {
     Title = title;
     CurrentVarroaCount = varroaCount;
 }
Exemplo n.º 9
0
 public AddVarroaCountViewModel(VarroaCount varroaCount)
 {
     _newVarroaCount = varroaCount;
 }
Exemplo n.º 10
0
 public AddCountViewModel(VarroaCount varroaCount)
 {
     _currentVarroaCount          = varroaCount;
     _currentVarroaCount.BistadId = "Angiv Id for Bistad";
 }