Beispiel #1
0
        public IActionResult Edit(int id, Diagnos diagnos)
        {
            if (id != diagnos.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(diagnos);
                    _db.Save();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DiagnosExists(diagnos.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(diagnos));
        }
Beispiel #2
0
 public IActionResult Create(Diagnos diagnos)
 {
     if (ModelState.IsValid)
     {
         _db.Create(diagnos);
         _db.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(diagnos));
 }
Beispiel #3
0
        public DiagnosisViewModel()
        {
            this.ComplicationsUncheckedCommand = new RelayCommand((x) =>
            {
                IsComplications       = false;
                Diagnos.Complications = null;
            });

            if (SingletonVMP.VMP.Diagnos == null)
            {
                Diagnos = new Diagnos();
                SingletonVMP.VMP.Diagnos = Diagnos;
            }
            else
            {
                Diagnos         = SingletonVMP.VMP.Diagnos;
                isComplications = !(string.IsNullOrEmpty(Diagnos.Complications) || string.IsNullOrWhiteSpace(Diagnos.Complications));
            }
        }
Beispiel #4
0
        public Diagnos manageDiagnos(DiagnosModel model)
        {
            using (var context = IoCContainer.Get <IEntity>())
            {
                var repositoryDiagnos = context.GetRepository <IRepository <Diagnos> >();

                var repositorySymptom = context.GetRepository <IRepository <Symptom> >();

                var repositoryWeight = context.GetRepository <IRepository <Weight> >();

                var newDiagnos = new Diagnos();
                if (model.id.HasValue)
                {
                    newDiagnos      = repositoryDiagnos.Find(new ById((int)model.id)).First();
                    newDiagnos.name = model.name;
                }
                else
                {
                    newDiagnos = new Diagnos
                    {
                        name = model.name
                    };

                    newDiagnos.weights = new List <Weight>();

                    repositorySymptom.GetAll().ToList().ForEach(t => {
                        var weight = new Weight(t, new Random().Next(0, 10));
                        repositoryWeight.Add(weight);
                        newDiagnos.weights.Add(weight);
                    });
                    repositoryDiagnos.Add(newDiagnos);
                }
                newDiagnos.image      = model.image;
                newDiagnos.descripton = model.descripton;

                context.SaveChanges();

                return(newDiagnos);
            }
        }
Beispiel #5
0
        public bool NyDiagnos(string beskrivning, string namn)
        {
            using (var db = new ZooContext())
            {
                Diagnos nyDiag = new Diagnos();

                nyDiag.Beskrivning = beskrivning;
                nyDiag.Namn        = namn;

                db.Diagnos.Add(nyDiag);
                db.SaveChanges();

                var nyttID = nyDiag.DiagnosID;

                if (nyDiag.DiagnosID > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #6
0
        public bool BestämdDiagnosFörBokning(int bokningsID, string diagnosNamn)
        {
            using (var db = new ZooContext())
            {
                Diagnos nyDiagnos = new Diagnos();
                nyDiagnos.Namn = diagnosNamn;

                db.Diagnos.Add(nyDiagnos);
                db.SaveChanges();

                BesökHosVeterinär besök = db.BesökHosVeterinär.Where(p => p.ID == bokningsID).FirstOrDefault();
                besök.DiagnosID = nyDiagnos.DiagnosID;
                db.SaveChanges();

                if (besök.ID > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #7
0
 public void Set(int zap, Diagnos diag)
 {
     Zapis.Add(zap, diag);
 }