예제 #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 });
     }
 }
예제 #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");
        }
예제 #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});
        }
예제 #4
0
 public bool Update(string id, Mock mock)
 {
     using (var session = dataContext.OpenSession())
     {
         return session.Mocks.Update(new ObjectId(id), mock);
     }
 }
예제 #5
0
 public MockResponseViewModel(Mock mock, MockResponse mockResponse)
 {
     Mock = mock;
     MockResponse = mockResponse;
 }