/// <summary> /// Create new call and add it to MongoDB /// </summary> /// <param name="entity"></param> /// <returns></returns> public string Add(CreateCallModel entity) { try { var date = DateTime.Parse(entity.CreatedOn); var _patient = GetPatient(entity.PatientCPR).Values.ToArray(); var newCall = new CallModel { _id = ObjectId.GenerateNewId().ToString(), PatientCPR = entity.PatientCPR, PatientName = _patient[2].ToString(), Department = _patient[3].ToString(), Room = _patient[4].ToString(), Bed = _patient[5].ToString(), Choice = entity.Choice, Category = entity.Category, Detail = entity.Detail, CreatedOn = date.ToString("t"), Status = (int) Enums.Active }; var call = _calls.InsertOneAsync(newCall.ToBsonDocument()); call.Wait(); _log.Debug("New call added"); return newCall._id; } catch (Exception ex) { _log.Exception(ex.Message); throw; } }
public void CallController_CreateNewCall_ReturnsActionResultWithCallIdInDescription() { Mock<ICallRepository> mock = new Mock<ICallRepository>(); var CUT = new CallController(mock.Object); var patient = new Patient() { _id = ObjectId.GenerateNewId().ToString(), ImportantInfo = "Denne skal ikke bruges alligevel :<", PatientCPR = "654321-4321", PatientName = "PATester" }; var newCall = new CreateCallModel() { PatientCPR = "654321-4321", Category = "TestCategory", Choice = "TestChoice", CreatedOn = DateTime.Now.ToString("F"), Detail = "TestDetail" }; var callId = CUT.CreateCall(newCall); Assert.IsNotNull(callId); }