public void UpdateSocialRelationship_Failure() { //Arrange Mock_SocialRelationship(); var updateSocialRelationship = new SocialRelationshipModel { SocialRelationshipID = -1, ContactID = 1, EncounterID = null, ReviewedNoChanges = true, TakenBy = 1, TakenTime = DateTime.Now, IsActive = true, ModifiedBy = 5, ModifiedOn = DateTime.Now, ForceRollback = true }; //Act var updateSocialRelationshipResult = socialRelationshipController.UpdateSocialRelationship(updateSocialRelationship); var response = updateSocialRelationshipResult as HttpResult <Response <SocialRelationshipModel> >; //Assert Assert.IsNotNull(response, "Response can't be null"); Assert.IsNotNull(response.Value, "Response value can't be null"); Assert.IsNotNull(response.Value.DataItems, "DataItems can't be null"); Assert.IsTrue(response.Value.DataItems.Count > 0, "Response must return data items"); Assert.IsTrue(!response.Value.DataItems[0].ReviewedNoChanges, "Social Relationship updated for invalid data."); }
public void AddSocialRelationship_Success() { //Act Mock_SocialRelationship(); var addSocialRelationship = new SocialRelationshipModel { SocialRelationshipID = 2, ContactID = 1, EncounterID = null, ReviewedNoChanges = false, TakenBy = 1, TakenTime = DateTime.Now, IsActive = true, ModifiedBy = 5, ModifiedOn = DateTime.Now, ForceRollback = true }; var addSocialRelationshipResult = socialRelationshipController.AddSocialRelationship(addSocialRelationship); var response = addSocialRelationshipResult as HttpResult <Response <SocialRelationshipModel> >; //Assert Assert.IsNotNull(response, "Response can't be null"); Assert.IsNotNull(response.Value, "Response value can't be null"); Assert.IsNotNull(response.Value.DataItems, "Response value can't be null"); Assert.IsTrue(response.Value.DataItems.Count == 2, "Social Relationship could not be created."); }
public void AddSocialRelationship_Failure() { //Arrange Mock_SocialRelationship(); var addSocialRelationshipFailure = new SocialRelationshipModel { SocialRelationshipID = -1, ContactID = -1, EncounterID = null, ReviewedNoChanges = false, TakenBy = 1, TakenTime = DateTime.Now, IsActive = true, ModifiedBy = 5, ModifiedOn = DateTime.Now, ForceRollback = true }; //Act var addSocialRelationshipResult = socialRelationshipController.AddSocialRelationship(addSocialRelationshipFailure); var response = addSocialRelationshipResult as HttpResult <Response <SocialRelationshipModel> >; //Assert Assert.IsNotNull(response, "Response can't be null"); Assert.IsNotNull(response.Value, "Response value can't be null"); Assert.IsNotNull(response.Value.DataItems, "Response value can't be null"); Assert.IsTrue(response.Value.DataItems.Count == 1, "Social Relationship created for invalid record."); }
/// <summary> /// Updates the social relationship. /// </summary> /// <param name="model">The sr.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public Response <SocialRelationshipModel> UpdateSocialRelationship(SocialRelationshipModel model) { var srParameters = BuildsrSpParams(model, true); var srRepository = unitOfWork.GetRepository <SocialRelationshipModel>(SchemaName.Clinical); return(unitOfWork.EnsureInTransaction(srRepository.ExecuteNQStoredProc, "usp_UpdateSocialRelationship", srParameters, forceRollback: model.ForceRollback.GetValueOrDefault(false))); }
/// <summary> /// Builds the sr sp parameters. /// </summary> /// <param name="sr">The sr.</param> /// <param name="isUpdate">if set to <c>true</c> [is update].</param> /// <returns></returns> private List <SqlParameter> BuildsrSpParams(SocialRelationshipModel sr, bool isUpdate) { var spParameters = new List <SqlParameter>(); if (isUpdate) { spParameters.Add(new SqlParameter("SocialRelationshipID", sr.SocialRelationshipID)); } spParameters.Add(new SqlParameter("ContactID", (object)sr.ContactID ?? DBNull.Value)); spParameters.Add(new SqlParameter("EncounterID", (object)sr.EncounterID ?? DBNull.Value)); spParameters.Add(new SqlParameter("ReviewedNoChanges", sr.ReviewedNoChanges)); spParameters.Add(new SqlParameter("TakenBy", (object)sr.TakenBy ?? DBNull.Value)); spParameters.Add(new SqlParameter("TakenTime", (object)sr.TakenTime ?? DBNull.Value)); spParameters.Add(new SqlParameter("ChildhoodHistory", (object)sr.ChildhoodHistory ?? DBNull.Value)); spParameters.Add(new SqlParameter("RelationshipHistory", (object)sr.RelationShipHistory ?? DBNull.Value)); spParameters.Add(new SqlParameter("FamilyHistory", (object)sr.FamilyHistory ?? DBNull.Value)); spParameters.Add(new SqlParameter("ModifiedOn", sr.ModifiedOn ?? DateTime.Now)); return(spParameters); }
public void UpdateSocialRelationship_Failure() { //Arrange const string url = baseRoute + "UpdateSocialRelationship"; var param = new NameValueCollection(); var srModel = new SocialRelationshipModel { SocialRelationshipID = -1, ContactID = -1, EncounterID = null, TakenBy = 1, TakenTime = DateTime.MinValue, ForceRollback = true }; //Act var response = _communicationManager.Put <SocialRelationshipModel, Response <SocialRelationshipModel> >(srModel, url); // Assert Assert.IsNotNull(response, "Response can not be null"); Assert.IsTrue(response.RowAffected == 0, "Social Relationship updated for invalid record."); }
public void UpdateSocialRelationship_Success() { //Arrange const string url = baseRoute + "UpdateSocialRelationship"; var param = new NameValueCollection(); var srModel = new SocialRelationshipModel { SocialRelationshipID = 10003, ContactID = 1, EncounterID = null, TakenBy = 1, TakenTime = DateTime.Now, ForceRollback = true }; //Act var response = _communicationManager.Put <SocialRelationshipModel, Response <SocialRelationshipModel> >(srModel, url); // Assert Assert.IsNotNull(response, "Response can not be null"); Assert.IsTrue(response.RowAffected > 2, "Social Relationship could not be updated."); }
/// <summary> /// To the model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public static SocialRelationshipModel ToModel(this SocialRelationshipViewModel model) { if (model == null) { return(null); } var entity = new SocialRelationshipModel { SocialRelationshipID = model.SocialRelationshipID, ContactID = model.ContactID, TakenBy = model.TakenBy, TakenTime = model.TakenTime, EncounterID = model.EncounterID, ChildhoodHistory = model.ChildhoodHistory, RelationShipHistory = model.RelationShipHistory, FamilyHistory = model.FamilyHistory, ForceRollback = model.ForceRollback, ModifiedOn = model.ModifiedOn }; return(entity); }
public void AddSocialRelationship_Failure() { //Arrange const string url = baseRoute + "AddSocialRelationship"; var param = new NameValueCollection(); var srModel = new SocialRelationshipModel { SocialRelationshipID = -1, ContactID = -1, EncounterID = null, ReviewedNoChanges = false, TakenBy = 1, TakenTime = DateTime.Now, ForceRollback = true }; //Act var response = _communicationManager.Post <SocialRelationshipModel, Response <SocialRelationshipModel> >(srModel, url); // Assert Assert.IsNotNull(response, "Response can not be null"); Assert.IsTrue(response.RowAffected <= 2, "Social Relationship created with invalid data."); }
/// <summary> /// To the view model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static SocialRelationshipViewModel ToViewModel(this SocialRelationshipModel entity) { if (entity == null) { return(null); } var model = new SocialRelationshipViewModel { SocialRelationshipID = entity.SocialRelationshipID, ContactID = entity.ContactID, TakenBy = entity.TakenBy, TakenTime = entity.TakenTime, EncounterID = entity.EncounterID, ChildhoodHistory = entity.ChildhoodHistory, RelationShipHistory = entity.RelationShipHistory, FamilyHistory = entity.FamilyHistory, ForceRollback = entity.ForceRollback, ModifiedOn = entity.ModifiedOn }; return(model); }
/// <summary> /// Updates the social relationship. /// </summary> /// <param name="model">The SocialRelationshipModel.</param> /// <returns></returns> public Response <SocialRelationshipModel> UpdateSocialRelationship(SocialRelationshipModel model) { const string apiUrl = BaseRoute + "UpdateSocialRelationship"; return(communicationManager.Put <SocialRelationshipModel, Response <SocialRelationshipModel> >(model, apiUrl)); }
public IHttpActionResult UpdateSocialRelationship(SocialRelationshipModel model) { return(new HttpResult <Response <SocialRelationshipModel> >(_socialRelationshipRuleEngine.UpdateSocialRelationship(model), Request)); }
/// <summary> /// Updates the social relationship. /// </summary> /// <param name="model">The SocialRelationshipModel.</param> /// <returns></returns> public Response <SocialRelationshipModel> UpdateSocialRelationship(SocialRelationshipModel model) { return(_socialRelationshipService.UpdateSocialRelationship(model)); }
public IHttpActionResult UpdateSocialRelationship(SocialRelationshipModel model) { return(new HttpResult <Response <SocialRelationshipModel> >(_socialRelationshipDataProvider.UpdateSocialRelationship(model), Request)); }