public void CanCompareDiveLocations()
        {
            DiveLocation instance = new DiveLocation();
            User user = new User();
            user.LoginCount = 3;
            user.LoginId = "larry";
            user.Password = "******";
            user.Created = System.DateTime.Now;
            user.LastModified = System.DateTime.Now;

            instance.Title = "Goodenough Spring";
            instance.User = user;

            DiveLocation instanceToCompareTo = new DiveLocation();
            instanceToCompareTo.Title = "Goodenough Spring";

            User user2 = new User();
            user.LoginCount = 3;
            user.LoginId = "larry";
            user.Password = "******";
            user.Created = System.DateTime.Now;
            user.LastModified = System.DateTime.Now;

            //instanceToCompareTo.User = user2; //breaks
            instanceToCompareTo.User = user; // works

            instance.ShouldEqual(instanceToCompareTo);
        }
        public ActionResult Create(DiveLocation diveLocation)
        {
            User user;
              if (ViewData.ModelState.IsValid) {
            diveLocation.Created = System.DateTime.Now;
            diveLocation.LastModified = System.DateTime.Now;
            user = userServices.FindUser(this.User.Identity.Name);
            diveLocation.User = user;
            diveLocation.UserId = user.Id;
            locationServices.Create(diveLocation);

            TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
              "The diveLocation was successfully created.";
            return RedirectToAction("Index");
              }

              DiveLocationFormViewModel viewModel = DiveLocationFormViewModel.CreateDiveLocationFormViewModel();
              viewModel.DiveLocation = diveLocation;
              return View(viewModel);
        }
Beispiel #3
0
        public virtual bool Equals(DiveLocation obj)
        {
            if (obj == null) return false;

              if (Equals(Created, obj.Created) == false)
            return false;

              if (Equals(Id, obj.Id) == false)
            return false;

              if (Equals(Title, obj.Title) == false)
            return false;

              if (Equals(LastModified, obj.LastModified) == false)
            return false;

              if (Equals(Notes, obj.Notes) == false)
            return false;

              if (Equals(User, obj.User) == false)
            return false;

              return true;
        }
 private void TransferFormValuesTo(DiveLocation diveLocationToUpdate, DiveLocation diveLocationFromForm)
 {
     //diveLocationToUpdate.Contact = diveLocationFromForm.Contact;
       diveLocationToUpdate.Title = diveLocationFromForm.Title;
       diveLocationToUpdate.Notes = diveLocationFromForm.Notes;
       diveLocationToUpdate.UserId = diveLocationFromForm.UserId;
       //diveLocationToUpdate.User = diveLocationFromForm.User;
       diveLocationToUpdate.LastModified = System.DateTime.Now;
 }
        public ActionResult Edit(DiveLocation diveLocation)
        {
            DiveLocation diveLocationToUpdate = locationServices.Get(diveLocation.Id);
              TransferFormValuesTo(diveLocationToUpdate, diveLocation);

              if (ViewData.ModelState.IsValid) {
            locationServices.Save(diveLocation);
            TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The diveLocation was successfully updated.";
            return RedirectToAction("Index");
              }
              else {
            DiveLocationFormViewModel viewModel = DiveLocationFormViewModel.CreateDiveLocationFormViewModel();
            viewModel.DiveLocation = diveLocation;
            return View(viewModel);
              }
        }