Exemple #1
0
        public void TestAddToInvetory()
        {
            Batch batch = new Batch();
            batch.Name = "Test";
            batch.Type = BatchType.Beer;
            batch.StartDate = DateTime.Now;

            context.Batches.Add(batch);
            context.SaveChanges();

            Container container = new Container();
            container.Batch = batch;
            container.Name = "Test container";
            container.Type = ContainerType.Bottle;
            container.Unit = ContainerVolumeUnits.Milliliter;
            container.Volume = 750;

            context.Containers.Add(container);
            context.SaveChanges();

            Cellar cellar = new Cellar();
            cellar.Name = "test cellar";
            cellar.Description = "My stash";
            cellar.Containers = new List<Container>();
            cellar.Containers.Add(container);

            context.Cellars.Add(cellar);
            context.SaveChanges();

            Assert.IsTrue(cellar.Containers.Contains(container));
        }
Exemple #2
0
        public static BatchComment createBatchComment(Batch batch, UserProfile user, string comment)
        {
            BrewersBuddyContext db = new BrewersBuddyContext();

            BatchComment batchComment = new BatchComment();
            batchComment.Batch = batch;
            batchComment.User = user;
            batchComment.Comment = comment;

            db.BatchComments.Add(batchComment);

            db.SaveChanges();

            return batchComment;
        }
Exemple #3
0
        public static BatchRating createBatchRating(Batch batch, UserProfile user, int rating, string comment)
        {
            BrewersBuddyContext db = new BrewersBuddyContext();

            BatchRating batchRating = new BatchRating();
            batchRating.Batch = batch;
            batchRating.User = user;
            batchRating.Rating = rating;
            batchRating.Comment = comment;

            db.BatchRatings.Add(batchRating);

            db.SaveChanges();

            return batchRating;
        }
Exemple #4
0
        public static BatchNote createBatchNote(Batch batch, String title, String text, UserProfile user)
        {
            BrewersBuddyContext db = new BrewersBuddyContext();

            BatchNote note = new BatchNote();
            note.Batch = batch;
            note.Text = text;
            note.Title = title;
            note.AuthorId = user.UserId;
            note.AuthorDate = DateTime.Now;

            db.BatchNotes.Add(note);
            db.SaveChanges();

            return note;
        }
Exemple #5
0
        public static Batch createBatch(String name, BatchType type, UserProfile owner)
        {
            BrewersBuddyContext db = new BrewersBuddyContext();

            Batch batch = new Batch();
            batch.Name = name;
            batch.Type = type;
            batch.OwnerId = owner.UserId;
            batch.StartDate = DateTime.Now;

            db.Batches.Add(batch);

            db.SaveChanges();

            return batch;
        }
Exemple #6
0
        public void TestAddMeasurement()
        {
            Batch batch = new Batch();
            batch.Name = "Test";
            batch.Type = BatchType.Wine;
            batch.StartDate = DateTime.Now;

            context.Batches.Add(batch);

            Measurement measurement = new Measurement();
            measurement.Batch = batch;
            measurement.Description = "This is a test!";
            measurement.Measured = "Gravity";
            measurement.Value = 1.01;
            measurement.MeasurementDate = DateTime.Now;

            context.Measurements.Add(measurement);
            context.SaveChanges();

            Assert.IsTrue(batch.Measurements.Contains(measurement));
        }
Exemple #7
0
        public void TestAddBatchAction()
        {
            Batch batch = new Batch();
            batch.Name = "Test";
            batch.Type = BatchType.Beer;
            batch.StartDate = DateTime.Now;

            context.Batches.Add(batch);

            BatchAction action = new BatchAction();
            action.Batch = batch;
            action.Description = "99 bottles of beer on the wall!";
            action.Type = ActionType.Bottle;
            action.Title = "Bottles the beer";
            action.ActionDate = DateTime.Now;

            context.BatchActions.Add(action);
            context.SaveChanges();

            Assert.IsTrue(batch.Actions.Contains(action));
        }
Exemple #8
0
        public static Measurement createMeasurement(Batch batch, String name, String description, String measured, Double value)
        {
            BrewersBuddyContext db = new BrewersBuddyContext();

            Measurement measurment = new Measurement();
            measurment.Batch = batch;
            measurment.Name = name;
            measurment.Description = description;
            measurment.Measured = measured;
            measurment.MeasurementDate = DateTime.Now;
            measurment.Value = value;

            db.Measurements.Add(measurment);
            db.SaveChanges();

            return measurment;
        }
 public ActionResult Edit(Batch batch)
 {
     if (ModelState.IsValid)
     {
         db.Entry(batch).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Details/" + batch.BatchId);
     }
     return View(batch);
 }
        public ActionResult Create(Batch batch)
        {
            if (ModelState.IsValid)
            {
                //Set the start date to now
                batch.StartDate = DateTime.Now;
                //Tie the object to the user
                batch.OwnerId = ControllerUtils.getCurrentUserId(User);

                db.Batches.Add(batch);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(batch);
        }