/// <summary>
        /// Updates the appointment contact.
        /// </summary>
        /// <param name="appointmentContact">The appointment contact.</param>
        /// <returns></returns>
        public Response <AppointmentContactModel> UpdateAppointmentContact(AppointmentContactModel appointmentContact)
        {
            var appointmentContactParameters = BuildAppointmentContactSpParams(appointmentContact, true);
            var appointmentContactRepository = unitOfWork.GetRepository <AppointmentContactModel>(SchemaName.Scheduling);

            return(appointmentContactRepository.ExecuteNQStoredProc("usp_UpdateAppointmentContactDetails", appointmentContactParameters));
        }
        /// <summary>
        /// Builds the appointment contact sp parameters.
        /// </summary>
        /// <param name="appointmentContact">The appointment contact.</param>
        /// <returns></returns>
        private List <SqlParameter> BuildAppointmentContactSpParams(AppointmentContactModel appointmentContact, bool isUpdate)
        {
            var spParameters = new List <SqlParameter>();

            if (isUpdate)
            {
                spParameters.Add(new SqlParameter("AppointmentContactID", appointmentContact.AppointmentContactID));
            }

            spParameters.Add(new SqlParameter("AppointmentID", appointmentContact.AppointmentID));
            spParameters.Add(new SqlParameter("ContactID", (object)appointmentContact.ContactID));
            spParameters.Add(new SqlParameter("ModifiedOn", appointmentContact.ModifiedOn ?? DateTime.Now));

            return(spParameters);
        }
        /// <summary>
        /// Converts viewmodel to model
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static AppointmentContactModel ToModel(this AppointmentContactViewModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = new AppointmentContactModel
            {
                AppointmentContactID = model.AppointmentContactID,
                AppointmentID        = model.AppointmentID,
                ContactID            = model.ContactID,
                ModifiedOn           = model.ModifiedOn
            };

            return(entity);
        }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static AppointmentContactViewModel ToViewModel(this AppointmentContactModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new AppointmentContactViewModel
            {
                AppointmentContactID = entity.AppointmentContactID,
                AppointmentID        = entity.AppointmentID,
                ContactID            = entity.ContactID,
                ModifiedOn           = entity.ModifiedOn
            };

            return(model);
        }
        public void AddAppointmentContact_Failed()
        {
            // Arrange
            var url = baseRoute + "addAppointmentContact";

            var appointmentContact = new AppointmentContactModel
            {
                AppointmentID = 1,
                ContactID     = 1
            };

            // Act
            var response = communicationManager.Post <AppointmentContactModel, Response <AppointmentContactModel> >(appointmentContact, url);

            // Assert
            Assert.IsTrue(response != null, "Response can't be null");
            Assert.IsTrue(response.ResultCode != 0, "Add appointment contact expected to be failed.");
        }
        public void UpdateAppointmentContact_Success()
        {
            // Arrange
            var url = baseRoute + "updateAppointmentContact";

            var appointmentContact = new AppointmentContactModel
            {
                AppointmentContactID = 1,
                AppointmentID        = 1,
                ContactID            = 1
            };

            // Act
            var response = communicationManager.Post <AppointmentContactModel, Response <AppointmentContactModel> >(appointmentContact, url);

            // Assert
            Assert.IsTrue(response != null, "Response can't be null");
            Assert.IsTrue(response.ResultCode == 0, "Appointment contact could not be updated.");
        }
        /// <summary>
        /// Updates the appointment contact.
        /// </summary>
        /// <param name="appointmentContact">The appointment contact.</param>
        /// <returns></returns>
        public Response <AppointmentContactModel> UpdateAppointmentContact(AppointmentContactModel appointmentContact)
        {
            const string apiUrl = BaseRoute + "UpdateAppointmentContact";

            return(_communicationManager.Put <AppointmentContactModel, Response <AppointmentContactModel> >(appointmentContact, apiUrl));
        }
 /// <summary>
 /// Updates the appointment contact.
 /// </summary>
 /// <param name="appointmentContact">The appointment contact.</param>
 /// <returns></returns>
 public Response <AppointmentContactModel> UpdateAppointmentContact(AppointmentContactModel appointmentContact)
 {
     return(appointmentService.UpdateAppointmentContact(appointmentContact));
 }
 /// <summary>
 /// Adds the appointment contact.
 /// </summary>
 /// <param name="appointmentContact">The appointment contact.</param>
 /// <returns></returns>
 public Response <AppointmentContactModel> AddAppointmentContact(AppointmentContactModel appointmentContact)
 {
     return(appointmentService.AddAppointmentContact(appointmentContact));
 }
 public IHttpActionResult UpdateAppointmentContact(AppointmentContactModel appointmentContact)
 {
     return(new HttpResult <Response <AppointmentContactModel> >(appointmentRuleEngine.UpdateAppointmentContact(appointmentContact), Request));
 }
 public IHttpActionResult UpdateAppointmentContact(AppointmentContactModel appointmentContact)
 {
     return(new HttpResult <Response <AppointmentContactModel> >(appointmentDataProvider.UpdateAppointmentContact(appointmentContact), Request));
 }