Beispiel #1
0
 public void Create(Mock mock)
 {
     using (var session = dataContext.OpenSession())
     {
         session.Mocks.Insert(mock);
         session.Mocks.EnsureIndex(x => x.Path, new IndexOptions { EmptyStringToNull = true, IgnoreCase = true, TrimWhitespace = true });
         session.Mocks.EnsureIndex(x => x.Verb, new IndexOptions { EmptyStringToNull = true, IgnoreCase = true, TrimWhitespace = true });
     }
 }
Beispiel #2
0
        public ActionResult Edit(string id, Mock model)
        {
            var mock = mockRepository.FindById(id);

            if (mock == null)
            {
                return MockNotFound(id);
            }

            // otherwise Responses gets overwritten. 
            model.Responses = mock.Responses;

            mockRepository.Update(id, model);

            return RedirectToAction("Index");
        }
Beispiel #3
0
        public ActionResult Create(Mock mock)
        {
            if (!ModelState.IsValid)
            {
                return View(mock);
            }

            var existing = mockRepository.Find(mock.Path, mock.Verb);

            if (existing != null)
            {
                ModelState.AddModelError("", $"There seems to be an existing mock with the path '{mock.Verb.ToString().ToUpper()} {mock.Path}'");
                return View(mock);
            }

            mockRepository.Create(mock);

            return RedirectToAction("Edit", new {id = mock.Id});
        }
Beispiel #4
0
 public bool Update(string id, Mock mock)
 {
     using (var session = dataContext.OpenSession())
     {
         return session.Mocks.Update(new ObjectId(id), mock);
     }
 }
 public MockResponseViewModel(Mock mock, MockResponse mockResponse)
 {
     Mock = mock;
     MockResponse = mockResponse;
 }