Example #1
0
        public bool CreateVaccine(VaccineModel model)
        {
            Vaccine newvaccine = new Vaccine
            {
                Comments   = model.Comments,
                Title      = model.Title,
                Expiration = model.Expiration,
                Received   = model.Received,
                Doctor     = model.Doctor,
                Company    = model.Company,
                Address    = model.Address,
                Created    = model.Created,
                Modified   = model.Modified,
                Deleted    = model.Deleted
            };

            using (ISession session = NHibernateSession.OpenSession())
            {
                Dog foundDog = session.Query <Dog>().FirstOrDefault(u => u.DogId == model.Dog.DogId.Value);
                if (foundDog == null)
                {
                    return(false);
                }
                newvaccine.Dog = foundDog;
                using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
                {
                    session.Save(newvaccine);                                 //  Save the user in session
                    transaction.Commit();                                     //  Commit the changes to the database
                }
            }
            return(true);
        }
Example #2
0
 public bool UpdateVaccine(VaccineModel model)
 {
     using (ISession session = NHibernateSession.OpenSession())
     {
         Vaccine foundvaccine = session.Query <Vaccine>().FirstOrDefault(c => c.VaccineId == model.VaccineId.Value);
         if (foundvaccine == null)
         {
             return(false);
         }
         foundvaccine.Modified   = DateTime.UtcNow;
         foundvaccine.Comments   = model.Comments;
         foundvaccine.Title      = model.Title;
         foundvaccine.Expiration = model.Expiration;
         foundvaccine.Received   = model.Received;
         foundvaccine.Doctor     = model.Doctor;
         foundvaccine.Company    = model.Company;
         foundvaccine.Address    = model.Address;
         using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
         {
             session.Update(foundvaccine);                             //  Save the user in session
             transaction.Commit();                                     //  Commit the changes to the database
         }
     }
     return(true);
 }
        // ctor
        public EditVaccineViewModel(VaccineModel vaccine, Guid childId)
        {
            // Property
            Vaccine = vaccine;
            ChildId = childId;

            // Command
            PutCommand = new Command(Put);
        }
Example #4
0
 public void AddData(MouseEventArgs e)
 {
     ShowEditData = true;
     Model        = new VaccineModel
     {
         Created = DateTime.UtcNow
     };
     StateHasChanged();
 }
        public AddVaccineViewModel(ChildModel _child)
        {
            // Property
            Child   = _child;
            Vaccine = new VaccineModel();


            // Command
            PostCommand = new Command(Post);
        }
Example #6
0
 public VaccinesBase()
 {
     Model = new VaccineModel
     {
         Created = DateTime.UtcNow
     };
     ShowEditData  = false;
     VaccineModels = new List <VaccineModel>();
     IncidentTypes = Enum.GetValues(typeof(IncidentType)).Cast <IncidentType>().Select(x => new IncidentTypeModel()
     {
         Name = x.ToString(), Value = (int)x
     });
 }
Example #7
0
        public VaccineModel GetVaccineById(VaccineId vaccineId)
        {
            VaccineModel model = new VaccineModel();

            using (ISession session = NHibernateSession.OpenSession())  // Open a session to conect to the database
            {
                var dbItem = session.Query <Vaccine>().FirstOrDefault(c => c.VaccineId == vaccineId.Value);
                if (dbItem != null)
                {
                    model = dbItem.ToVaccineModel();
                }
            }
            return(model);
        }
        // ctor
        public ChildVaccineViewModel(ChildModel child)
        {
            // Property
            Child          = child;
            VaccineList    = new ObservableCollection <VaccineModel>();
            CurrentVaccine = new VaccineModel();

            // Get
            Get();


            // Command
            SaveAsPDFCommand       = new Command(SaveAsPDF);
            GoToSubPutPageCommand  = new Command(GoToPutPage);
            SubDeleteCommand       = new Command(Delete);
            GoToSubPostPageCommand = new Command(GoToPostPage);
            PullRefreshCommand     = new Command(Refresh);
        }
        public async void Delete()
        {
            if (CurrentVaccine?.FId != null && CurrentVaccine.VaccinePeriod != null)
            {
                var isDeleteAccepted = await StandardMessagesDisplay.DeleteDisplayMessage(CurrentVaccine.VaccineStatus);

                if (isDeleteAccepted)
                {
                    var deleteResponse = await DataService.Delete($"Vaccine/{Child?.Id}/{CurrentVaccine.FId}");

                    if (deleteResponse == "ConnectionError")
                    {
                        StandardMessagesDisplay.NoConnectionToast();
                    }
                    else if (deleteResponse == "Error")
                    {
                        StandardMessagesDisplay.Error();
                    }
                    else if (deleteResponse == "ErrorTracked")
                    {
                        StandardMessagesDisplay.ErrorTracked();
                    }
                    else if (deleteResponse == "null")
                    {
                        StandardMessagesDisplay.ItemDeletedToast();

                        VaccineList?.Remove(CurrentVaccine);
                        CurrentVaccine = new VaccineModel();
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                StandardMessagesDisplay.NoDataDisplayMessage();
            }
        }
Example #10
0
 public VaccineCreateRequest()
 {
     Vaccine = new VaccineModel();
 }
Example #11
0
 public VaccineUpdateRequest()
 {
     Vaccine = new VaccineModel();
 }
Example #12
0
 public void PutVaccine(VaccineModel model)
 {
     VaccineModel data = new VaccineModel();
     // data.Create(model);
 }
Example #13
0
 public void DeleteVaccine(int Id)
 {
     VaccineModel data = new VaccineModel();
     // data.Create(model);
 }
Example #14
0
 public void EditData(MouseEventArgs e, VaccineModel model)
 {
     ShowEditData = true;
     Model        = model;
     StateHasChanged();
 }