Exemple #1
0
        public bool CreateBoarding(BoardingModel model)
        {
            Boarding newBoarding = new Boarding
            {
                Comments      = model.Comments,
                Company       = model.Company,
                Address       = model.Address,
                Reason        = model.Reason,
                PaymentAmount = model.PaymentAmount,
                Website       = model.Website,
                StartDateTime = model.StartDateTime,
                EndDateTime   = model.EndDateTime,
                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);
                }
                newBoarding.Dog = foundDog;
                using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
                {
                    session.Save(newBoarding);                                //  Save the user in session
                    transaction.Commit();                                     //  Commit the changes to the database
                }
            }
            return(true);
        }
Exemple #2
0
 public bool UpdateBoarding(BoardingModel model)
 {
     using (ISession session = NHibernateSession.OpenSession())
     {
         Boarding foundBoarding = session.Query <Boarding>().FirstOrDefault(c => c.BoardingId == model.BoardingId.Value);
         if (foundBoarding == null)
         {
             return(false);
         }
         foundBoarding.Modified      = DateTime.UtcNow;
         foundBoarding.Comments      = model.Comments;
         foundBoarding.Company       = model.Company;
         foundBoarding.Address       = model.Address;
         foundBoarding.Reason        = model.Reason;
         foundBoarding.PaymentAmount = model.PaymentAmount;
         foundBoarding.Website       = model.Website;
         foundBoarding.StartDateTime = model.StartDateTime;
         foundBoarding.EndDateTime   = model.EndDateTime;
         using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
         {
             session.Update(foundBoarding);                            //  Save the user in session
             transaction.Commit();                                     //  Commit the changes to the database
         }
     }
     return(true);
 }
 public BoardingBase()
 {
     Model = new BoardingModel
     {
         Created = DateTime.UtcNow
     };
     ShowEditData   = false;
     BoardingModels = new List <BoardingModel>();
 }
 public void AddData(MouseEventArgs e)
 {
     ShowEditData = true;
     Model        = new BoardingModel
     {
         Created = DateTime.UtcNow
     };
     StateHasChanged();
 }
Exemple #5
0
        public BoardingModel GetBoardingById(BoardingId boardingId)
        {
            BoardingModel model = new BoardingModel();

            using (ISession session = NHibernateSession.OpenSession())  // Open a session to conect to the database
            {
                var dbItem = session.Query <Boarding>().FirstOrDefault(c => c.BoardingId == boardingId.Value);
                if (dbItem != null)
                {
                    model = dbItem.ToBoardingModel();
                }
            }
            return(model);
        }
 public void EditData(MouseEventArgs e, BoardingModel model)
 {
     ShowEditData = true;
     Model        = model;
     StateHasChanged();
 }
 public BoardingCreateRequest()
 {
     Boarding = new BoardingModel();
 }