//Data Insert in Organizaton Table public ResponseModel InsertOrgAndUser(UserProfileModel model) { try { cmd = new SqlCommand("InsertOrgAndUser_Sp", con); if (model.UserCityId == 0 && model.UserCity != null) { CityModel cityModel = new CityModel(); cityModel.CityName = model.UserCity; cityModel.CreatedBy = model.CreatedBy; ResponseModel responseModel = cityObj.InsertCity(cityModel); model.UserCityId = responseModel.Response; } if (model.UserStateId == 0 && model.UserState != null) { StateModel model3 = new StateModel(); model3.StateName = model.UserState; model3.CreatedBy = model.CreatedBy; ResponseModel model1 = stateObj.InsertState(model3); model.UserStateId = model1.Response; } if (model.OrgCityId == 0 && model.OrgCity != null) { CityModel cityModel = new CityModel(); cityModel.CityName = model.OrgCity; cityModel.CreatedBy = model.CreatedBy; ResponseModel responseModel = cityObj.InsertCity(cityModel); model.OrgCityId = responseModel.Response; } if (model.OrgStateId == 0 && model.OrgState != null) { StateModel model3 = new StateModel(); model3.StateName = model.OrgState; model3.CreatedBy = model.CreatedBy; ResponseModel model1 = stateObj.InsertState(model3); model.OrgStateId = model1.Response; } if (model.RoleId == 0 && model.RoleName != null) { RoleModel model3 = new RoleModel(); model3.RoleName = model.RoleName; model3.CreatedByOrg_Id = model.OrgId; model3.CreatedByUser_Id = model.CreatedBy; ResponseModel model1 = InsertRole(model3); model.RoleId = model1.Response; } //Organization_Tbl Fields if (model.OrgId > 0) cmd.Parameters.Add("@OrgId", SqlDbType.BigInt).Value = model.OrgId; cmd.Parameters.Add("@Name", SqlDbType.VarChar, 400).Value = model.OrgName; cmd.Parameters.Add("@Street", SqlDbType.NVarChar, 100).Value = model.OrgStreet; if (model.OrgCityId > 0) cmd.Parameters.Add("@CityId", SqlDbType.BigInt).Value = model.OrgCityId; if (model.OrgStateId > 0) cmd.Parameters.Add("@StateId", SqlDbType.BigInt).Value = model.OrgStateId; cmd.Parameters.Add("@RegisteredAs", SqlDbType.VarChar, 50).Value = model.RegisteredAs; cmd.Parameters.Add("@Logo", SqlDbType.NVarChar, 150).Value = model.Logo; //User_Tbl Fields if (model.UserId > 0) cmd.Parameters.Add("@UserId", SqlDbType.BigInt).Value = model.UserId; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 70).Value = model.UserFirstName; cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 70).Value = model.UserLastName; cmd.Parameters.Add("@U_Street", SqlDbType.NVarChar, 100).Value = model.UserStreet; if (model.UserCityId > 0) cmd.Parameters.Add("@U_CityId", SqlDbType.BigInt).Value = model.UserCityId; if (model.UserStateId > 0) cmd.Parameters.Add("@U_StateId", SqlDbType.BigInt).Value = model.UserStateId; cmd.Parameters.Add("@ProfilePhoto", SqlDbType.NVarChar).Value = model.ProfilePhoto; cmd.Parameters.Add("@RoleId", SqlDbType.Int).Value = model.RoleId; cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 200).Value = model.UserName; cmd.Parameters.Add("@EmailId", SqlDbType.NVarChar, 150).Value = model.UserEmailId; cmd.Parameters.Add("@MobileNo", SqlDbType.NVarChar, 13).Value = model.UserMobileNo; cmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = PasswordSecurity.Encrypt(model.Password);//Password Encryption cmd.Parameters.Add("@U_IsActive", SqlDbType.Bit).Value = model.User_IsActive; cmd.Parameters.Add("@U_IsDelete", SqlDbType.Bit).Value = model.User_IsDelete; //Common Fields cmd.Parameters.Add("@CreatedBy", SqlDbType.BigInt).Value = model.CreatedBy; cmd.Parameters.Add("@IsActive", SqlDbType.Bit).Value = model.IsActive; cmd.Parameters.Add("@IsDelete", SqlDbType.Bit).Value = model.IsDelete; cmd.Parameters.Add("@Result_OrgId", SqlDbType.BigInt).Direction = ParameterDirection.Output; cmd.Parameters.Add("@Result_UserId", SqlDbType.BigInt).Direction = ParameterDirection.Output; cmd.CommandType = CommandType.StoredProcedure; if (con.State == ConnectionState.Closed) { con.Open(); } cmd.ExecuteNonQuery(); message = "Success"; if (con.State == ConnectionState.Open) con.Close(); } catch (Exception ex) { obj.Message = ex.Message; ret = 0; } obj.Response = ret; return obj; }
public ResponseModel InsertOrgAndUser(UserProfileModel model) { return obj.InsertOrgAndUser(model); }