Esempio n. 1
0
 private static void AddCommonParams(ProviderAddRequest model, SqlParameterCollection col)
 {
     col.AddWithValue("@TitleTypeId", model.TitleTypeId);
     col.AddWithValue("@UserProfileId", model.UserProfileId);
     col.AddWithValue("@GenderTypeId", model.GenderTypeId);
     col.AddWithValue("@Phone", model.Phone);
     col.AddWithValue("@Fax", model.Fax);
     col.AddWithValue("@Networks", model.Networks);
     col.AddWithValue("@NPI", model.NPI);
     col.AddWithValue("@GenderAccepted", model.GenderAccepted);
     col.AddWithValue("@IsAccepting", model.IsAccepting);
 }
Esempio n. 2
0
 private static void ModifyInsertParams(SqlParameterCollection paramCol, ProviderAddRequest provider)
 {
     paramCol.AddWithValue("@TitleTypeId", provider.TitleTypeId);
     paramCol.AddWithValue("@GenderTypeId", provider.GenderTypeId);
     paramCol.AddWithValue("@Phone", provider.Phone);
     paramCol.AddWithValue("@Fax", provider.Fax);
     paramCol.AddWithValue("@FirstName", provider.UserProfile.FirstName);
     paramCol.AddWithValue("@LastName", provider.UserProfile.LastName);
     paramCol.AddWithValue("@Mi", provider.UserProfile.Mi);
     paramCol.AddWithValue("@AvatarUrl", provider.UserProfile.AvatarUrl);
     paramCol.AddWithValue("@NPI", provider.ProfessionalDetails.NPI);
     paramCol.AddWithValue("@GenderAccepted", provider.ProfessionalDetails.GenderAccepted);
     paramCol.AddWithValue("@Email", provider.User.Email);
 }
        public ActionResult <ItemResponse <int> > Create(ProviderAddRequest model)
        {
            int          code     = 201;
            BaseResponse response = null;

            try
            {
                int userId = _authService.GetCurrentUserId();
                int id     = _service.Add(model, userId);
                response = new ItemResponse <int> {
                    Item = id
                };                                               // Provider Id
            }
            catch (Exception ex)
            {
                code     = 500;
                response = new ErrorResponse($"ArgumentException Error: {ex.ToString() }");
                base.Logger.LogError(ex.ToString());
            }
            return(StatusCode(code, response));
        }
        public ActionResult <ItemResponse <int> > InsertV2(ProviderAddRequest provider)
        {
            ObjectResult result = null;

            try
            {
                int userId = _auth.GetCurrentUserId();
                int newId  = _service.InsertV2(provider, userId);
                ItemResponse <int> response = new ItemResponse <int> {
                    Item = newId
                };
                result = Created201(response);
            }
            catch (Exception ex)
            {
                base.Logger.LogError(ex.ToString());
                ErrorResponse response = new ErrorResponse(ex.Message);
                result = StatusCode(500, response);
            }
            return(result);
        }
Esempio n. 5
0
        public int Add(ProviderAddRequest model, int userId)
        {
            int    id       = 0;
            string procName = "[dbo].[ProviderDetails_Insert_V4]";

            DataTable affiliationsTable      = null;
            DataTable certificationsTable    = null;
            DataTable expertiseTable         = null;
            DataTable languagesTable         = null;
            DataTable licensesTable          = null;
            DataTable locationsTable         = null;
            DataTable practicesTable         = null;
            DataTable practiceLanguagesTable = null;
            DataTable servicesTable          = null;
            DataTable specializationsTable   = null;

            if (model.Affiliations != null)
            {
                affiliationsTable = MapAffiliationsToTable(model.Affiliations);
            }
            if (model.Certifications != null)
            {
                certificationsTable = MapCertificationsToTable(model.Certifications);
            }
            if (model.ExpertiseList != null)
            {
                expertiseTable = MapExpertiseToTable(model.ExpertiseList);
            }
            if (model.Languages != null)
            {
                languagesTable = MapLanguagesToTable(model.Languages);
            }
            if (model.Licenses != null)
            {
                licensesTable = MapLicensesToTable(model.Licenses);
            }
            if (model.Locations != null)
            {
                locationsTable = MapLocationsToTable(model.Locations);
            }
            if (model.Practices != null)
            {
                practicesTable = MapPracticesToTable(model.Practices);
            }
            if (model.PracticeLanguages != null)
            {
                practiceLanguagesTable = MapPracticeLanguagesToTable(model.PracticeLanguages);
            }
            if (model.Services != null)
            {
                servicesTable = MapServicesToTable(model.Services);
            }
            if (model.Specializations != null)
            {
                specializationsTable = MapSpecializationsToTable(model.Specializations);
            }

            _data.ExecuteNonQuery(procName,
                                  inputParamMapper : delegate(SqlParameterCollection col)
            {
                AddCommonParams(model, col);
                AddTables(col
                          , affiliationsTable
                          , certificationsTable
                          , expertiseTable
                          , languagesTable
                          , licensesTable
                          , locationsTable
                          , practicesTable
                          , practiceLanguagesTable
                          , servicesTable
                          , specializationsTable
                          );
                col.AddWithValue("@CreatedBy", userId);

                SqlParameter idOut = new SqlParameter("@ProviderId", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;

                col.Add(idOut);
            },
                                  returnParameters : delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@ProviderId"].Value;
                int.TryParse(oId.ToString(), out id);
            }
                                  );
            return(id);
        }